From 3f24d5d25363a17963027526a8531202e8f3cd6e Mon Sep 17 00:00:00 2001 From: Dianna Hohensee Date: Thu, 16 Mar 2023 13:35:11 +0000 Subject: SERVER-74895 Expect command errors in validation when querying $collStats (cherry picked from commit 80caaf6c05cc0a9bb5f5e0458c671ba7ffd528b5) --- src/mongo/db/commands/validate.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index 93de718940e..f7a4fe0cbf8 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -39,6 +39,7 @@ #include "mongo/db/query/internal_plans.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" @@ -112,10 +113,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, -- cgit v1.2.1