From 34ea442dda453616265650377d8d68404195c46f Mon Sep 17 00:00:00 2001 From: Romans Kasperovics Date: Mon, 2 May 2022 09:19:16 +0000 Subject: SERVER-65319 Count explicit use of allowDiskUse:false --- src/mongo/db/commands/find_cmd.cpp | 4 ++++ src/mongo/db/commands/run_aggregate.cpp | 11 ++++++----- src/mongo/db/commands/run_aggregate.h | 4 ++++ 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/mongo/db/commands') diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 3aabc3ddf6b..4847a7e93c4 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -559,6 +559,10 @@ public: return; } + if (!cq->getFindCommandRequest().getAllowDiskUse().value_or(true)) { + allowDiskUseFalseCounter.increment(); + } + // Check whether we are allowed to read from this node after acquiring our locks. uassertStatusOK(replCoord->checkCanServeReadsFor( opCtx, nss, ReadPreferenceSetting::get(opCtx).canRunOnSecondary())); diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index 4a7a59f2fd1..9832ef54847 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -98,10 +98,11 @@ using std::string; using std::stringstream; using std::unique_ptr; +Counter64 allowDiskUseFalseCounter; + namespace { -Counter64 allowDiskUseCounter; -ServerStatusMetricField allowDiskUseMetric{"commands.aggregate.allowDiskUseTrue", - &allowDiskUseCounter}; +ServerStatusMetricField allowDiskUseMetric{"query.allowDiskUseFalse", + &allowDiskUseFalseCounter}; /** * If a pipeline is empty (assuming that a $cursor stage hasn't been created yet), it could mean @@ -907,8 +908,8 @@ Status runAggregate(OperationContext* opCtx, auto pipeline = Pipeline::parse(request.getPipeline(), expCtx); expCtx->stopExpressionCounters(); - if (request.getAllowDiskUse()) { - allowDiskUseCounter.increment(); + if (!request.getAllowDiskUse().value_or(true)) { + allowDiskUseFalseCounter.increment(); } // Check that the view's collation matches the collation of any views involved in the diff --git a/src/mongo/db/commands/run_aggregate.h b/src/mongo/db/commands/run_aggregate.h index bbfbf7da892..b61538fb93d 100644 --- a/src/mongo/db/commands/run_aggregate.h +++ b/src/mongo/db/commands/run_aggregate.h @@ -69,4 +69,8 @@ Status runAggregate(OperationContext* opCtx, const PrivilegeVector& privileges, rpc::ReplyBuilderInterface* result); +/** + * Tracks explicit use of allowDiskUse:false with find and aggregate commands. + */ +extern Counter64 allowDiskUseFalseCounter; } // namespace mongo -- cgit v1.2.1