diff options
author | Mickey. J Winters <mickey.winters@mongodb.com> | 2021-07-07 15:18:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-07 15:43:04 +0000 |
commit | a862b5d0279bb681634f698def16b90c1117b3f5 (patch) | |
tree | 12a9ac60b7ca84f1be01cf85c895060e795d1abe /src/mongo | |
parent | 2a41fb45f89a9b7b51053f9b448d767ba074684e (diff) | |
download | mongo-a862b5d0279bb681634f698def16b90c1117b3f5.tar.gz |
SERVER-53859 Add queryHash to the mongos slow query logs
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/curop.cpp | 9 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_find.cpp | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 72454cd9420..75e0684aaf9 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -917,7 +917,8 @@ string OpDebug::report(OperationContext* opCtx, const SingleThreadedLockStats* l if (queryHash) { s << " queryHash:" << zeroPaddedHex(*queryHash); - invariant(planCacheKey); + } + if (planCacheKey) { s << " planCacheKey:" << zeroPaddedHex(*planCacheKey); } @@ -1100,7 +1101,8 @@ void OpDebug::report(OperationContext* opCtx, if (queryHash) { pAttrs->addDeepCopy("queryHash", zeroPaddedHex(*queryHash)); - invariant(planCacheKey); + } + if (planCacheKey) { pAttrs->addDeepCopy("planCacheKey", zeroPaddedHex(*planCacheKey)); } @@ -1249,7 +1251,8 @@ void OpDebug::append(OperationContext* opCtx, if (queryHash) { b.append("queryHash", zeroPaddedHex(*queryHash)); - invariant(planCacheKey); + } + if (planCacheKey) { b.append("planCacheKey", zeroPaddedHex(*planCacheKey)); } diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp index c85ca0abffb..ed6d2985361 100644 --- a/src/mongo/s/query/cluster_find.cpp +++ b/src/mongo/s/query/cluster_find.cpp @@ -49,6 +49,7 @@ #include "mongo/db/curop_failpoint_helpers.h" #include "mongo/db/pipeline/change_stream_invalidation_info.h" #include "mongo/db/query/canonical_query.h" +#include "mongo/db/query/canonical_query_encoder.h" #include "mongo/db/query/find_common.h" #include "mongo/db/query/getmore_command_gen.h" #include "mongo/db/query/query_planner_common.h" @@ -496,6 +497,8 @@ CursorId ClusterFind::runQuery(OperationContext* opCtx, const ReadPreferenceSetting& readPref, std::vector<BSONObj>* results, bool* partialResultsReturned) { + CurOp::get(opCtx)->debug().queryHash = canonical_query_encoder::computeHash(query.encodeKey()); + // If the user supplied a 'partialResultsReturned' out-parameter, default it to false here. if (partialResultsReturned) { *partialResultsReturned = false; |