Skip to content

Commit 4a90388

Browse files
csum112MongoDB Bot
authored andcommitted
SERVER-99808 Re-introduce queryHash for backwards compatibility (#31568)
GitOrigin-RevId: f1059bc
1 parent 3dfcaee commit 4a90388

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

jstests/libs/query/analyze_plan.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ export function getPlanCacheKeyFromExplain(explain) {
10201020
* Get the 'planCacheShapeHash' from 'object'.
10211021
*/
10221022
export function getPlanCacheShapeHashFromObject(object) {
1023-
// TODO SERVER 93305: Remove deprecated 'queryHash' usages.
1023+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
10241024
const planCacheShapeHash = object.planCacheShapeHash || object.queryHash;
10251025
assert.neq(planCacheShapeHash, undefined);
10261026
return planCacheShapeHash;

src/mongo/db/curop.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,10 @@ void OpDebug::report(OperationContext* opCtx,
12651265
}
12661266

12671267
if (planCacheShapeHash) {
1268-
pAttrs->addDeepCopy("planCacheShapeHash", zeroPaddedHex(*planCacheShapeHash));
1268+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
1269+
std::string planCacheShapeHashStr = zeroPaddedHex(*planCacheShapeHash);
1270+
pAttrs->addDeepCopy("planCacheShapeHash", planCacheShapeHashStr);
1271+
pAttrs->addDeepCopy("queryHash", planCacheShapeHashStr);
12691272
}
12701273
if (planCacheKey) {
12711274
pAttrs->addDeepCopy("planCacheKey", zeroPaddedHex(*planCacheKey));
@@ -1485,7 +1488,10 @@ void OpDebug::append(OperationContext* opCtx,
14851488
}
14861489

14871490
if (planCacheShapeHash) {
1488-
b.append("planCacheShapeHash", zeroPaddedHex(*planCacheShapeHash));
1491+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
1492+
std::string planCacheShapeHashStr = zeroPaddedHex(*planCacheShapeHash);
1493+
b.append("planCacheShapeHash", planCacheShapeHashStr);
1494+
b.append("queryHash", planCacheShapeHashStr);
14891495
}
14901496
if (planCacheKey) {
14911497
b.append("planCacheKey", zeroPaddedHex(*planCacheKey));
@@ -1800,6 +1806,12 @@ std::function<BSONObj(ProfileFilter::Args)> OpDebug::appendStaged(StringSet requ
18001806
b.append(field, zeroPaddedHex(*args.op.planCacheShapeHash));
18011807
}
18021808
});
1809+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
1810+
addIfNeeded("queryHash", [](auto field, auto args, auto& b) {
1811+
if (args.op.planCacheShapeHash) {
1812+
b.append(field, zeroPaddedHex(*args.op.planCacheShapeHash));
1813+
}
1814+
});
18031815
addIfNeeded("planCacheKey", [](auto field, auto args, auto& b) {
18041816
if (args.op.planCacheKey) {
18051817
b.append(field, zeroPaddedHex(*args.op.planCacheKey));

src/mongo/db/query/explain.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ void generatePlannerInfo(PlanExecutor* exec,
150150
}
151151

152152
if (planCacheShapeHash) {
153-
plannerBob.append("planCacheShapeHash", zeroPaddedHex(*planCacheShapeHash));
153+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
154+
std::string planCacheShapeHashStr = zeroPaddedHex(*planCacheShapeHash);
155+
plannerBob.append("queryHash", planCacheShapeHashStr);
156+
plannerBob.append("planCacheShapeHash", planCacheShapeHashStr);
154157
}
155158

156159
if (planCacheKeyHash) {
@@ -352,7 +355,10 @@ BSONObj explainVersionToBson(const PlanExplainer::ExplainVersion& version) {
352355

353356
template <typename EntryType>
354357
void appendBasicPlanCacheEntryInfoToBSON(const EntryType& entry, BSONObjBuilder* out) {
355-
out->append("planCacheShapeHash", zeroPaddedHex(entry.planCacheShapeHash));
358+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
359+
std::string planCacheShapeHashStr = zeroPaddedHex(entry.planCacheShapeHash);
360+
out->append("queryHash", planCacheShapeHashStr);
361+
out->append("planCacheShapeHash", planCacheShapeHashStr);
356362
out->append("planCacheKey", zeroPaddedHex(entry.planCacheKey));
357363
out->append("isActive", entry.isActive);
358364
out->append("works",

src/mongo/db/query/plan_cache/plan_cache_callbacks.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ void logCreateInactiveCacheEntry(std::string&& query,
5555
"Creating inactive cache entry for query",
5656
"query"_attr = redact(query),
5757
"planCacheShapeHash"_attr = planCacheShapeHash,
58+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
59+
"queryHash"_attr = planCacheShapeHash,
5860
"planCacheKey"_attr = planCacheKey,
5961
"newWorks"_attr = newWorks);
6062
}
@@ -69,6 +71,8 @@ void logReplaceActiveCacheEntry(std::string&& query,
6971
"Replacing active cache entry for query",
7072
"query"_attr = redact(query),
7173
"planCacheShapeHash"_attr = planCacheShapeHash,
74+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
75+
"queryHash"_attr = planCacheShapeHash,
7276
"planCacheKey"_attr = planCacheKey,
7377
"oldWorks"_attr = works,
7478
"newWorks"_attr = newWorks);
@@ -85,6 +89,8 @@ void logNoop(std::string&& query,
8589
"an active cache entry with a lower works value",
8690
"query"_attr = redact(query),
8791
"planCacheShapeHash"_attr = planCacheShapeHash,
92+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
93+
"queryHash"_attr = planCacheShapeHash,
8894
"planCacheKey"_attr = planCacheKey,
8995
"oldWorks"_attr = works,
9096
"newWorks"_attr = newWorks);
@@ -100,6 +106,8 @@ void logIncreasingWorkValue(std::string&& query,
100106
"Increasing work value associated with cache entry",
101107
"query"_attr = redact(query),
102108
"planCacheShapeHash"_attr = planCacheShapeHash,
109+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
110+
"queryHash"_attr = planCacheShapeHash,
103111
"planCacheKey"_attr = planCacheKey,
104112
"oldWorks"_attr = works,
105113
"increasedWorks"_attr = increasedWorks);
@@ -115,6 +123,8 @@ void logPromoteCacheEntry(std::string&& query,
115123
"Inactive cache entry for query is being promoted to active entry",
116124
"query"_attr = redact(query),
117125
"planCacheShapeHash"_attr = planCacheShapeHash,
126+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
127+
"queryHash"_attr = planCacheShapeHash,
118128
"planCacheKey"_attr = planCacheKey,
119129
"oldWorks"_attr = works,
120130
"newWorks"_attr = newWorks);
@@ -132,6 +142,8 @@ void logUnexpectedPinnedCacheEntry(std::string&& query,
132142
"Found unexpected pinned plan cache entry",
133143
"query"_attr = redact(query),
134144
"planCacheShapeHash"_attr = planCacheShapeHash,
145+
// TODO SERVER-93305: Remove deprecated 'queryHash' usages.
146+
"queryHash"_attr = planCacheShapeHash,
135147
"planCacheKey"_attr = planCacheKey,
136148
"oldEntry"_attr = oldEntry,
137149
"newEntry"_attr = newEntry,

0 commit comments

Comments
 (0)