summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Dobroshynski <andrii.dobroshynski@mongodb.com>2021-03-03 22:37:43 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-04 16:12:11 +0000
commit4de2d9458ba9358ca29f097c8f835c1e20c05fde (patch)
treed54e53bf860c4eb3b748ca024000389f9c159df8
parent0b4dccad8115c1355597fdf79ccd6fe06ba8a2d3 (diff)
downloadmongo-4de2d9458ba9358ca29f097c8f835c1e20c05fde.tar.gz
SERVER-54930 Fix sbe_explain_helpers.js breaking parallel tester
-rw-r--r--jstests/core/idhack.js17
-rw-r--r--jstests/core/index_filter_commands.js7
-rw-r--r--jstests/libs/sbe_explain_helpers.js9
3 files changed, 19 insertions, 14 deletions
diff --git a/jstests/core/idhack.js b/jstests/core/idhack.js
index c16f7348aa8..5403daef2ce 100644
--- a/jstests/core/idhack.js
+++ b/jstests/core/idhack.js
@@ -12,6 +12,11 @@ t.drop();
load("jstests/libs/analyze_plan.js");
load("jstests/libs/sbe_explain_helpers.js");
+const isSBEEnabled = (() => {
+ const getParam = db.adminCommand({getParameter: 1, featureFlagSBE: 1});
+ return getParam.hasOwnProperty("featureFlagSBE") && getParam.featureFlagSBE.value;
+})();
+
assert.commandWorked(t.insert({_id: {x: 1}, z: 1}));
assert.commandWorked(t.insert({_id: {x: 2}, z: 2}));
assert.commandWorked(t.insert({_id: {x: 3}, z: 3}));
@@ -38,26 +43,26 @@ const query = {
let explain = t.find(query).explain("allPlansExecution");
assert.eq(1, explain.executionStats.nReturned, explain);
assert.eq(1, explain.executionStats.totalKeysExamined, explain);
-assertIdHackPlan(db, getWinningPlan(explain.queryPlanner), "FETCH");
+assertIdHackPlan(db, getWinningPlan(explain.queryPlanner), "FETCH", isSBEEnabled);
// ID hack cannot be used with hint().
t.createIndex({_id: 1, a: 1});
explain = t.find(query).hint({_id: 1, a: 1}).explain();
-assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner));
+assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner), isSBEEnabled);
// ID hack cannot be used with skip().
explain = t.find(query).skip(1).explain();
-assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner));
+assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner), isSBEEnabled);
// ID hack cannot be used with a regex predicate.
assert.commandWorked(t.insert({_id: "abc"}));
explain = t.find({_id: /abc/}).explain();
assert.eq({_id: "abc"}, t.findOne({_id: /abc/}));
-assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner));
+assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner), isSBEEnabled);
// Covered query returning _id field only can be handled by ID hack.
explain = t.find(query, {_id: 1}).explain();
-assertIdHackPlan(db, getWinningPlan(explain.queryPlanner), "PROJECTION_COVERED");
+assertIdHackPlan(db, getWinningPlan(explain.queryPlanner), "PROJECTION_COVERED", isSBEEnabled);
// Check doc from covered ID hack query.
assert.eq({_id: {x: 2}}, t.findOne(query, {_id: 1}), explain);
@@ -104,5 +109,5 @@ assert.eq(0, t.find({_id: 1}).hint({_id: 1}).max({_id: 0}).itcount());
assert.eq(0, t.find({_id: 1}).hint({_id: 1}).min({_id: 2}).itcount());
explain = t.find({_id: 2}).hint({_id: 1}).min({_id: 1}).max({_id: 3}).explain();
-assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner));
+assertNonIdHackPlan(db, getWinningPlan(explain.queryPlanner), isSBEEnabled);
})();
diff --git a/jstests/core/index_filter_commands.js b/jstests/core/index_filter_commands.js
index 7ff5bbe5715..2369ac7e4fe 100644
--- a/jstests/core/index_filter_commands.js
+++ b/jstests/core/index_filter_commands.js
@@ -153,7 +153,12 @@ coll.find(queryA1, projectionA1).sort(sortA1).hint(indexA1).itcount();
assert.commandWorked(coll.runCommand('planCacheSetFilter', {query: queryID, indexes: [indexA1]}));
var explain = coll.explain("executionStats").find(queryID).finish();
assert.commandWorked(explain);
-assertIdHackPlan(db, getWinningPlan(explain.queryPlanner), "FETCH");
+
+const isSBEEnabled = (() => {
+ const getParam = db.adminCommand({getParameter: 1, featureFlagSBE: 1});
+ return getParam.hasOwnProperty("featureFlagSBE") && getParam.featureFlagSBE.value;
+})();
+assertIdHackPlan(db, getWinningPlan(explain.queryPlanner), "FETCH", isSBEEnabled);
// Clear filters
// Clearing filters on a missing collection should be a no-op.
diff --git a/jstests/libs/sbe_explain_helpers.js b/jstests/libs/sbe_explain_helpers.js
index 2980352e505..1ad1c722dfa 100644
--- a/jstests/libs/sbe_explain_helpers.js
+++ b/jstests/libs/sbe_explain_helpers.js
@@ -5,14 +5,9 @@
// Include helpers for analyzing explain output.
load("jstests/libs/analyze_plan.js");
-const isSBEEnabled = (() => {
- const getParam = db.adminCommand({getParameter: 1, featureFlagSBE: 1});
- return getParam.hasOwnProperty("featureFlagSBE") && getParam.featureFlagSBE.value;
-})();
-
// SBE does not support building IDHACK plans. As such, if SBE is being used, we assert that the
// generated plan is an 'expectedParentStageForIxScan' + IXSCAN over the _id index.
-function assertIdHackPlan(db, root, expectedParentStageForIxScan) {
+function assertIdHackPlan(db, root, expectedParentStageForIxScan, isSBEEnabled) {
if (isSBEEnabled) {
const parentStage = getPlanStage(root, expectedParentStageForIxScan);
assert.neq(parentStage, null, root);
@@ -29,7 +24,7 @@ function assertIdHackPlan(db, root, expectedParentStageForIxScan) {
// When SBE is enabled, we assert that the generated plan used an IXSCAN. Otherwise, we assert that
// 'isIdhack' returns false.
-function assertNonIdHackPlan(db, root) {
+function assertNonIdHackPlan(db, root, isSBEEnabled) {
if (isSBEEnabled) {
assert(isIxscan(db, root), root);
} else {