diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2023-03-16 13:35:11 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-03-29 16:28:07 +0000 |
commit | 9b200f4c1d6b8fa118e98571e38ec7bede2f07d2 (patch) | |
tree | c0da418ec8a8d7af8f0c3ae248bc562111692ea9 | |
parent | 6b9275d8629aac59912bcee8cb3cf4dbe86da2b9 (diff) | |
download | mongo-9b200f4c1d6b8fa118e98571e38ec7bede2f07d2.tar.gz |
SERVER-74895 Expect command errors in validation when querying $collStats
(cherry picked from commit 80caaf6c05cc0a9bb5f5e0458c671ba7ffd528b5)
-rw-r--r-- | src/mongo/db/commands/validate.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index 3edefd48a04..fbd029812e7 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -40,6 +40,7 @@ #include "mongo/db/storage/durable_catalog.h" #include "mongo/db/storage/record_store.h" #include "mongo/logv2/log.h" +#include "mongo/rpc/get_status_from_command_result.h" #include "mongo/util/fail_point.h" #include "mongo/util/scopeguard.h" #include "mongo/util/testing_proctor.h" @@ -113,10 +114,12 @@ void logCollStats(OperationContext* opCtx, const NamespaceString& nss) { BSONObj collStatsResult; try { // Run $collStats via aggregation. - // Any command errors will throw and be caught in the 'catch'. client.runCommand(nss.db().toString(), makeCollStatsCommand(nss.coll()), collStatsResult /* command return results */); + // Logging $collStats information is best effort. If the collection doesn't exist, for + // example, then the $collStats query will fail and the failure reason will be logged. + uassertStatusOK(getStatusFromWriteCommandReply(collStatsResult)); verifyCommandResponse(collStatsResult); LOGV2_OPTIONS(7463200, |