summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJennifer Peshansky <jennifer.peshansky@mongodb.com>2021-12-15 15:23:07 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-21 00:44:41 +0000
commitf348e7d2b2bd9f4a5c45ced40362cbe707db7453 (patch)
treed93ab81c8f996a2754c719361504b84a81d0d3ab /src
parentc6ef7fcde0489294fbb650b6b7f1b8787d8307f1 (diff)
downloadmongo-f348e7d2b2bd9f4a5c45ced40362cbe707db7453.tar.gz
SERVER-59754 Prevent get_executor from overwriting information set by an outer pipeline
(cherry picked from commit 4970d9626853e3b916aab3d911bcf4aba23e8c88) (cherry picked from commit da0cacc0c3f3aa6e8b3405443aa2011c5e6d8220)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/query/get_executor.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 88d298ac0de..0a7a6922413 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -488,13 +488,17 @@ StatusWith<PrepareExecutionResult> prepareExecution(OperationContext* opCtx,
// Check that the query should be cached.
if (CollectionQueryInfo::get(collection).getPlanCache()->shouldCacheQuery(*canonicalQuery)) {
- // Fill in opDebug information.
+ // Fill in opDebug information, unless it has already been filled by an outer pipeline.
const auto planCacheKey =
CollectionQueryInfo::get(collection).getPlanCache()->computeKey(*canonicalQuery);
- CurOp::get(opCtx)->debug().queryHash =
- canonical_query_encoder::computeHash(planCacheKey.getStableKeyStringData());
- CurOp::get(opCtx)->debug().planCacheKey =
- canonical_query_encoder::computeHash(planCacheKey.toString());
+ OpDebug& opDebug = CurOp::get(opCtx)->debug();
+ if (!opDebug.queryHash) {
+ opDebug.queryHash =
+ canonical_query_encoder::computeHash(planCacheKey.getStableKeyStringData());
+ }
+ if (!opDebug.planCacheKey) {
+ opDebug.planCacheKey = canonical_query_encoder::computeHash(planCacheKey.toString());
+ }
// Try to look up a cached solution for the query.
if (auto cs = CollectionQueryInfo::get(collection)