diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands/plan_cache_clear_command.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/pipeline/pipeline_d.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/query/canonical_query.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/query/canonical_query.h | 8 | ||||
-rw-r--r-- | src/mongo/db/query/canonical_query_encoder.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/canonical_query_encoder_test.cpp | 36 | ||||
-rw-r--r-- | src/mongo/db/query/explain.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/plan_cache_key_info_test.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/query/query_knobs.idl | 10 | ||||
-rw-r--r-- | src/mongo/db/query/query_planner.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/query_planner_columnar_test.cpp | 3 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_multiplan.cpp | 3 | ||||
-rw-r--r-- | src/mongo/shell/servers.js | 35 |
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 eb56632a9bd..1609577347e 100644 --- a/src/mongo/db/commands/plan_cache_clear_command.cpp +++ b/src/mongo/db/commands/plan_cache_clear_command.cpp @@ -90,7 +90,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 c1d80e84ade..69d3711e080 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 f760e1f5be1..865cd10b245 100644 --- a/src/mongo/db/query/canonical_query.cpp +++ b/src/mongo/db/query/canonical_query.cpp @@ -193,7 +193,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()) { @@ -543,7 +543,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 3f997eb1f8b..98780fb00a1 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) { @@ -302,8 +302,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 aa65a0cf6ae..303cdb6009a 100644 --- a/src/mongo/db/query/canonical_query_encoder.cpp +++ b/src/mongo/db/query/canonical_query_encoder.cpp @@ -665,7 +665,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 bfbfd63d08e..8b801dcb33b 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -1374,7 +1374,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 34f9a9616c7..e1d9c5a2b00 100644 --- a/src/mongo/db/query/query_planner.cpp +++ b/src/mongo/db/query/query_planner.cpp @@ -204,7 +204,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 930bf3055c9..cd38a5fd843 100644 --- a/src/mongo/db/query/query_planner_columnar_test.cpp +++ b/src/mongo/db/query/query_planner_columnar_test.cpp @@ -69,8 +69,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 bf688fb06bd..165ee334be4 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) { |