summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@10gen.com>2022-05-19 15:33:37 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-19 16:41:34 +0000
commit89945d5b9581f1baadc78a46fd87a07c090d053c (patch)
tree222f15736146298ef637682f2b05994577d1246a /src/mongo
parent3805148358ae9b82e5f3b9307bd25fbf7a4dd4b5 (diff)
downloadmongo-89945d5b9581f1baadc78a46fd87a07c090d053c.tar.gz
SERVER-66551 Rename internalQueryEnableSlotBasedExecutionEngine back to internalQueryForceClassicEngine
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/commands/plan_cache_clear_command.cpp2
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp6
-rw-r--r--src/mongo/db/query/canonical_query.cpp4
-rw-r--r--src/mongo/db/query/canonical_query.h8
-rw-r--r--src/mongo/db/query/canonical_query_encoder.cpp2
-rw-r--r--src/mongo/db/query/canonical_query_encoder_test.cpp36
-rw-r--r--src/mongo/db/query/explain.cpp2
-rw-r--r--src/mongo/db/query/get_executor.cpp2
-rw-r--r--src/mongo/db/query/plan_cache_key_info_test.cpp12
-rw-r--r--src/mongo/db/query/query_knobs.idl10
-rw-r--r--src/mongo/db/query/query_planner.cpp2
-rw-r--r--src/mongo/db/query/query_planner_columnar_test.cpp3
-rw-r--r--src/mongo/dbtests/query_stage_multiplan.cpp3
-rw-r--r--src/mongo/shell/servers.js35
14 files changed, 42 insertions, 85 deletions
diff --git a/src/mongo/db/commands/plan_cache_clear_command.cpp b/src/mongo/db/commands/plan_cache_clear_command.cpp
index a3e8fcfc1fb..daf4bb18937 100644
--- a/src/mongo/db/commands/plan_cache_clear_command.cpp
+++ b/src/mongo/db/commands/plan_cache_clear_command.cpp
@@ -92,7 +92,7 @@ Status clear(OperationContext* opCtx,
// sbe::isQuerySbeCompatible here.
const size_t plannerOptions = 0;
if (feature_flags::gFeatureFlagSbePlanCache.isEnabledAndIgnoreFCV() &&
- cq->getEnableSlotBasedExecutionEngine() &&
+ !cq->getForceClassicEngine() &&
sbe::isQuerySbeCompatible(&collection, cq.get(), plannerOptions)) {
cq->setSbeCompatible(true);
sbe::getPlanCache(opCtx).remove(
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index ff034ff6cc0..fbba650d37d 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -110,14 +110,14 @@ namespace {
* pipeline to prepare for pushdown of $group and $lookup into the inner query layer so that it
* can be executed using SBE.
* Group stages are extracted from the pipeline when all of the following conditions are met:
- * 0. When the 'internalQueryEnableSlotBasedExecutionEngine' feature flag is 'true'.
+ * 0. When the 'internalQueryForceClassicEngine' feature flag is 'false'.
* 1. When 'allowDiskUse' is false. We currently don't support spilling in the SBE HashAgg
* stage. This will change once that is supported when SERVER-58436 is complete.
* 2. When the DocumentSourceGroup has 'doingMerge=false', this will change when we implement
* hash table spilling in SERVER-58436.
*
* Lookup stages are extracted from the pipeline when all of the following conditions are met:
- * 0. When the 'internalQueryEnableSlotBasedExecutionEngine' feature flag is 'true'.
+ * 0. When the 'internalQueryForceClassicEngine' feature flag is 'false'.
* 1. When the 'featureFlagSBELookupPushdown' feature flag is 'true'.
* 2. The $lookup uses only the 'localField'/'foreignField' syntax (no pipelines).
* 3. The foreign collection is neither sharded nor a view.
@@ -138,7 +138,7 @@ std::vector<std::unique_ptr<InnerPipelineStageInterface>> extractSbeCompatibleSt
}
// No pushdown if we're using the classic engine.
- if (!cq->getEnableSlotBasedExecutionEngine()) {
+ if (cq->getForceClassicEngine()) {
return {};
}
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp
index 7df5350daac..2271f4ce494 100644
--- a/src/mongo/db/query/canonical_query.cpp
+++ b/src/mongo/db/query/canonical_query.cpp
@@ -195,7 +195,7 @@ Status CanonicalQuery::init(OperationContext* opCtx,
_findCommand = std::move(findCommand);
_canHaveNoopMatchNodes = canHaveNoopMatchNodes;
- _enableSlotBasedExecutionEngine = internalQueryEnableSlotBasedExecutionEngine.load();
+ _forceClassicEngine = internalQueryForceClassicEngine.load();
auto validStatus = isValid(root.get(), *_findCommand);
if (!validStatus.isOK()) {
@@ -545,7 +545,7 @@ CanonicalQuery::QueryShapeString CanonicalQuery::encodeKey() const {
// TODO SERVER-61507: remove '_pipeline.empty()' check. Canonical queries with pushed down
// $group/$lookup stages are not SBE-compatible until SERVER-61507 is complete.
return (feature_flags::gFeatureFlagSbePlanCache.isEnabledAndIgnoreFCV() &&
- _enableSlotBasedExecutionEngine && _sbeCompatible && _pipeline.empty())
+ !_forceClassicEngine && _sbeCompatible && _pipeline.empty())
? canonical_query_encoder::encodeSBE(*this)
: canonical_query_encoder::encode(*this);
}
diff --git a/src/mongo/db/query/canonical_query.h b/src/mongo/db/query/canonical_query.h
index 9f25a92740b..661b66f0458 100644
--- a/src/mongo/db/query/canonical_query.h
+++ b/src/mongo/db/query/canonical_query.h
@@ -221,8 +221,8 @@ public:
return _explain;
}
- bool getEnableSlotBasedExecutionEngine() const {
- return _enableSlotBasedExecutionEngine;
+ bool getForceClassicEngine() const {
+ return _forceClassicEngine;
}
void setSbeCompatible(bool sbeCompatible) {
@@ -304,8 +304,8 @@ private:
bool _explain = false;
- // Determines whether the SBE engine is enabled.
- bool _enableSlotBasedExecutionEngine = false;
+ // Determines whether the classic engine must be used.
+ bool _forceClassicEngine = true;
// True if this query can be executed by the SBE.
bool _sbeCompatible = false;
diff --git a/src/mongo/db/query/canonical_query_encoder.cpp b/src/mongo/db/query/canonical_query_encoder.cpp
index bfbaa2544c5..a6a94915e91 100644
--- a/src/mongo/db/query/canonical_query_encoder.cpp
+++ b/src/mongo/db/query/canonical_query_encoder.cpp
@@ -667,7 +667,7 @@ CanonicalQuery::QueryShapeString encode(const CanonicalQuery& cq) {
// This encoding can be removed once the classic query engine reaches EOL and SBE is used
// exclusively for all query execution.
- keyBuilder << kEncodeEngineSection << (cq.getEnableSlotBasedExecutionEngine() ? "t" : "f");
+ keyBuilder << kEncodeEngineSection << (cq.getForceClassicEngine() ? "f" : "t");
return keyBuilder.str();
}
diff --git a/src/mongo/db/query/canonical_query_encoder_test.cpp b/src/mongo/db/query/canonical_query_encoder_test.cpp
index 27e8ae74707..486b4f2d14f 100644
--- a/src/mongo/db/query/canonical_query_encoder_test.cpp
+++ b/src/mongo/db/query/canonical_query_encoder_test.cpp
@@ -148,9 +148,8 @@ TEST(CanonicalQueryEncoderTest, ComputeKey) {
// The computed key depends on which execution engine is enabled. As such, we disable SBE for
// this test so that the test doesn't break should the default value of
- // 'internalQueryEnableSlotBasedExecutionEngine' change in the future.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", false);
+ // 'internalQueryForceClassicEngine' change in the future.
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", true);
// No sorts
testComputeKey("{}", "{}", "{}", "an@f");
@@ -224,9 +223,8 @@ TEST(CanonicalQueryEncoderTest, ComputeKey) {
TEST(CanonicalQueryEncoderTest, EncodeNotEqualNullPredicates) {
// The computed key depends on which execution engine is enabled. As such, we disable SBE for
// this test so that the test doesn't break should the default value of
- // 'internalQueryEnableSlotBasedExecutionEngine' change in the future.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", false);
+ // 'internalQueryForceClassicEngine' change in the future.
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", true);
// With '$eq', '$gte', and '$lte' negation comparison to 'null'.
testComputeKey("{a: {$not: {$eq: null}}}", "{}", "{_id: 0, a: 1}", "ntnot_eq_null[eqa]|a@f");
@@ -246,9 +244,8 @@ TEST(CanonicalQueryEncoderTest, EncodeNotEqualNullPredicates) {
TEST(CanonicalQueryEncoderTest, ComputeKeyEscaped) {
// The computed key depends on which execution engine is enabled. As such, we disable SBE for
// this test so that the test doesn't break should the default value of
- // 'internalQueryEnableSlotBasedExecutionEngine' change in the future.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", false);
+ // 'internalQueryForceClassicEngine' change in the future.
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", true);
// Field name in query.
testComputeKey("{'a,[]~|-<>': 1}", "{}", "{}", "eqa\\,\\[\\]\\~\\|\\-<>@f");
@@ -284,9 +281,8 @@ TEST(CanonicalQueryEncoderTest, ComputeKeyGeoWithin) {
TEST(CanonicalQueryEncoderTest, ComputeKeyGeoNear) {
// The computed key depends on which execution engine is enabled. As such, we disable SBE for
// this test so that the test doesn't break should the default value of
- // 'internalQueryEnableSlotBasedExecutionEngine' change in the future.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", false);
+ // 'internalQueryForceClassicEngine' change in the future.
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", true);
testComputeKey("{a: {$near: [0,0], $maxDistance:0.3 }}", "{}", "{}", "gnanrfl@f");
testComputeKey("{a: {$nearSphere: [0,0], $maxDistance: 0.31 }}", "{}", "{}", "gnanssp@f");
@@ -301,8 +297,7 @@ TEST(CanonicalQueryEncoderTest, ComputeKeyGeoNear) {
TEST(CanonicalQueryEncoderTest, ComputeKeyRegexDependsOnFlags) {
// The computed key depends on which execution engine is enabled. As such, we enable SBE for
// this test in order to ensure that we have coverage for both SBE and the classic engine.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", true);
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", false);
testComputeKey("{a: {$regex: \"sometext\"}}", "{}", "{}", "rea@t");
testComputeKey("{a: {$regex: \"sometext\", $options: \"\"}}", "{}", "{}", "rea@t");
@@ -335,9 +330,8 @@ TEST(CanonicalQueryEncoderTest, ComputeKeyRegexDependsOnFlags) {
TEST(CanonicalQueryEncoderTest, ComputeKeyMatchInDependsOnPresenceOfRegexAndFlags) {
// The computed key depends on which execution engine is enabled. As such, we disable SBE for
// this test so that the test doesn't break should the default value of
- // 'internalQueryEnableSlotBasedExecutionEngine' change in the future.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", false);
+ // 'internalQueryForceClassicEngine' change in the future.
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", true);
// Test that an $in containing a single regex is unwrapped to $regex.
testComputeKey("{a: {$in: [/foo/]}}", "{}", "{}", "rea@f");
@@ -386,9 +380,8 @@ TEST(CanonicalQueryEncoderTest, ComputeKeyMatchInDependsOnPresenceOfRegexAndFlag
TEST(CanonicalQueryEncoderTest, CheckCollationIsEncoded) {
// The computed key depends on which execution engine is enabled. As such, we disable SBE for
// this test so that the test doesn't break should the default value of
- // 'internalQueryEnableSlotBasedExecutionEngine' change in the future.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", false);
+ // 'internalQueryForceClassicEngine' change in the future.
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", true);
unique_ptr<CanonicalQuery> cq(canonicalize(
fromjson("{a: 1, b: 1}"), {}, {}, fromjson("{locale: 'mock_reverse_string'}")));
@@ -400,8 +393,7 @@ TEST(CanonicalQueryEncoderTest, ComputeKeySBE) {
// Generated cache keys should be treated as opaque to the user.
// SBE must be enabled in order to generate SBE plan cache keys.
- RAIIServerParameterControllerForTest controllerSBE(
- "internalQueryEnableSlotBasedExecutionEngine", true);
+ RAIIServerParameterControllerForTest controllerSBE("internalQueryForceClassicEngine", false);
// TODO SERVER-61314: Remove when featureFlagSbePlanCache is removed.
RAIIServerParameterControllerForTest controllerSBEPlanCache("featureFlagSbePlanCache", true);
diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp
index 4ec9e8d9e7d..414badb8332 100644
--- a/src/mongo/db/query/explain.cpp
+++ b/src/mongo/db/query/explain.cpp
@@ -96,7 +96,7 @@ void generatePlannerInfo(PlanExecutor* exec,
QuerySettingsDecoration::get(collection->getSharedDecorations());
if (exec->getCanonicalQuery()->isSbeCompatible() &&
feature_flags::gFeatureFlagSbePlanCache.isEnabledAndIgnoreFCV() &&
- exec->getCanonicalQuery()->getEnableSlotBasedExecutionEngine() &&
+ !exec->getCanonicalQuery()->getForceClassicEngine() &&
// TODO(SERVER-61507): Remove pipeline check once lowered pipelines are integrated with
// SBE plan cache.
exec->getCanonicalQuery()->pipeline().empty()) {
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 537ec7d5c69..f1a6be4d958 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -1386,7 +1386,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutor(
const auto& mainColl = collections.getMainCollection();
canonicalQuery->setSbeCompatible(
sbe::isQuerySbeCompatible(&mainColl, canonicalQuery.get(), plannerOptions));
- return canonicalQuery->getEnableSlotBasedExecutionEngine() && canonicalQuery->isSbeCompatible()
+ return !canonicalQuery->getForceClassicEngine() && canonicalQuery->isSbeCompatible()
? getSlotBasedExecutor(opCtx,
collections,
std::move(canonicalQuery),
diff --git a/src/mongo/db/query/plan_cache_key_info_test.cpp b/src/mongo/db/query/plan_cache_key_info_test.cpp
index 472b1f0ab9c..7235386e7f4 100644
--- a/src/mongo/db/query/plan_cache_key_info_test.cpp
+++ b/src/mongo/db/query/plan_cache_key_info_test.cpp
@@ -420,17 +420,17 @@ TEST(PlanCacheKeyInfoTest, DifferentQueryEngines) {
false, // sparse
IndexEntry::Identifier{""})}; // name
- // Helper to construct a plan cache key given the 'enableSlotBasedExecutionEngine' flag.
- auto constructPlanCacheKey = [&](bool enableSlotBasedExecutionEngine) {
- RAIIServerParameterControllerForTest controller{
- "internalQueryEnableSlotBasedExecutionEngine", enableSlotBasedExecutionEngine};
+ // Helper to construct a plan cache key given the 'forceClassicEngine' flag.
+ auto constructPlanCacheKey = [&](bool forceClassicEngine) {
+ RAIIServerParameterControllerForTest controller{"internalQueryForceClassicEngine",
+ forceClassicEngine};
const auto queryStr = "{a: 0}";
unique_ptr<CanonicalQuery> cq(canonicalize(queryStr));
return makeKey(*cq, indexCores);
};
- const auto classicEngineKey = constructPlanCacheKey(false);
- const auto noClassicEngineKey = constructPlanCacheKey(true);
+ const auto classicEngineKey = constructPlanCacheKey(true);
+ const auto noClassicEngineKey = constructPlanCacheKey(false);
// Check that the two plan cache keys are not equal because the plans were created under
// different engines.
diff --git a/src/mongo/db/query/query_knobs.idl b/src/mongo/db/query/query_knobs.idl
index 5120ec5f1d3..7e2fee1563f 100644
--- a/src/mongo/db/query/query_knobs.idl
+++ b/src/mongo/db/query/query_knobs.idl
@@ -653,13 +653,13 @@ server_parameters:
default: false
on_update: plan_cache_util::clearSbeCacheOnParameterChange
- internalQueryEnableSlotBasedExecutionEngine:
- description: "If true, the system will use the SBE execution engine for eligible queries,
- otherwise all queries will execute using the classic execution engine."
+ internalQueryForceClassicEngine:
+ description: "If true, the system will use the classic execution engine for all queries,
+ otherwise eligible queries will execute using the SBE execution engine."
set_at: [ startup, runtime ]
- cpp_varname: "internalQueryEnableSlotBasedExecutionEngine"
+ cpp_varname: "internalQueryForceClassicEngine"
cpp_vartype: AtomicWord<bool>
- default: false
+ default: true
internalQueryAppendIdToSetWindowFieldsSort:
description: "If true, appends _id to the sort stage generated by desugaring $setWindowFields to
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index 69c679888f8..fa810499cb4 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -212,7 +212,7 @@ void tryToAddColumnScan(const QueryPlannerParams& params,
// We only want to use the columnar index if we can avoid fetching the whole document.
return;
}
- if (!query.isSbeCompatible() || !query.getEnableSlotBasedExecutionEngine()) {
+ if (!query.isSbeCompatible() || query.getForceClassicEngine()) {
// We only support column scans in SBE.
return;
}
diff --git a/src/mongo/db/query/query_planner_columnar_test.cpp b/src/mongo/db/query/query_planner_columnar_test.cpp
index 10c92f6cebd..2d255ebbeeb 100644
--- a/src/mongo/db/query/query_planner_columnar_test.cpp
+++ b/src/mongo/db/query/query_planner_columnar_test.cpp
@@ -85,8 +85,7 @@ protected:
private:
// SBE must be enabled in order to test columnar indexes.
- RAIIServerParameterControllerForTest _controllerSBE{
- "internalQueryEnableSlotBasedExecutionEngine", true};
+ RAIIServerParameterControllerForTest _controllerSBE{"internalQueryForceClassicEngine", false};
};
TEST_F(QueryPlannerColumnarTest, InclusionProjectionUsesColumnarIndex) {
diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp
index ce40f343858..3552cf095fd 100644
--- a/src/mongo/dbtests/query_stage_multiplan.cpp
+++ b/src/mongo/dbtests/query_stage_multiplan.cpp
@@ -551,8 +551,7 @@ TEST_F(QueryStageMultiPlanTest, MPSExplainAllPlans) {
//
// This is a regression test for SERVER-20111.
TEST_F(QueryStageMultiPlanTest, MPSSummaryStats) {
- RAIIServerParameterControllerForTest controller("internalQueryEnableSlotBasedExecutionEngine",
- false);
+ RAIIServerParameterControllerForTest controller("internalQueryForceClassicEngine", true);
const int N = 5000;
for (int i = 0; i < N; ++i) {
diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js
index 9d39eced9a9..c48527ba68f 100644
--- a/src/mongo/shell/servers.js
+++ b/src/mongo/shell/servers.js
@@ -643,20 +643,6 @@ var _isMongodVersionEqualOrAfter = function(version1, version2) {
return false;
};
-// Returns if version2 came before version 1.
-var _isMongodVersionBefore = function(version1, version2) {
- var versionParts1 = _convertVersionToIntegerArray(version1);
- var versionParts2 = _convertVersionToIntegerArray(version2);
- if (versionParts2[0] < versionParts1[0] ||
- (versionParts2[0] === versionParts1[0] && versionParts2[1] < versionParts1[1]) ||
- (versionParts2[0] === versionParts1[0] && versionParts2[1] === versionParts1[1] &&
- versionParts2[2] < versionParts1[2])) {
- return true;
- }
-
- return false;
-};
-
// Removes a setParameter parameter from mongods or mongoses running a version that won't recognize
// them.
var _removeSetParameterIfBeforeVersion = function(
@@ -672,24 +658,6 @@ var _removeSetParameterIfBeforeVersion = function(
}
};
-// Similar to the function above, but accepts two versions such that if the configured binVersion is
-// between the specified versions, it removes the setParameter parameter.
-var _removeSetParameterIfBetweenSpecifiedVersions = function(
- opts, parameterName, afterVersion, beforeVersion, isMongos = false) {
- var processString = isMongos ? "mongos" : "mongod";
- var versionCompatible = (opts.binVersion === "" || opts.binVersion === undefined ||
- // For 'opts.binVersion' to be compatible with 'parameterName', it must
- // be GTE 'afterVersion' or LT 'beforeVersion'.
- _isMongodVersionEqualOrAfter(afterVersion, opts.binVersion) ||
- _isMongodVersionBefore(beforeVersion, opts.binVersion));
- if (!versionCompatible && opts.setParameter && opts.setParameter[parameterName] != undefined) {
- print("Removing '" + parameterName + "' setParameter with value " +
- opts.setParameter[parameterName] + " because it isn't compatible with " +
- processString + " running version " + opts.binVersion);
- delete opts.setParameter[parameterName];
- }
-};
-
/**
* @option {object} opts
*
@@ -735,8 +703,7 @@ MongoRunner.mongodOptions = function(opts = {}) {
opts, "enableDefaultWriteConcernUpdatesForInitiate", "5.0.0");
_removeSetParameterIfBeforeVersion(opts, "enableReconfigRollbackCommittedWritesCheck", "5.0.0");
_removeSetParameterIfBeforeVersion(opts, "featureFlagRetryableFindAndModify", "5.0.0");
- _removeSetParameterIfBetweenSpecifiedVersions(
- opts, "internalQueryEnableSlotBasedExecutionEngine", "6.0.0", "5.1.0");
+ _removeSetParameterIfBeforeVersion(opts, "internalQueryForceClassicEngine", "5.1.0");
_removeSetParameterIfBeforeVersion(opts, "allowMultipleArbiters", "5.3.0");
if (!opts.logFile && opts.useLogFiles) {