diff options
author | Hana Pearlman <hana.pearlman@mongodb.com> | 2023-04-06 18:18:20 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-06 23:10:24 +0000 |
commit | a69cf3209b0596c5814f71f1a69657abd78adf54 (patch) | |
tree | 40854c4b72bc1b3e7d9b804fbf7cbce02426e6a0 /src/mongo/db/query/framework_control.cpp | |
parent | dc12789334b1d7f08bbcc57e1b9f8991a65a4f83 (diff) | |
download | mongo-a69cf3209b0596c5814f71f1a69657abd78adf54.tar.gz |
SERVER-75054: Change default of internalQueryFrameworkControl to trySbeEngine
Changes the default for internalQueryFrameworkControl to
trySbeEngine from tryBonsai. After the change, if the CQF
feature flag is off, trying to set the control knob to
tryBonsai or forceBonsai will fail.
Diffstat (limited to 'src/mongo/db/query/framework_control.cpp')
-rw-r--r-- | src/mongo/db/query/framework_control.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/mongo/db/query/framework_control.cpp b/src/mongo/db/query/framework_control.cpp index 0a2f35dfb7f..41a74540e85 100644 --- a/src/mongo/db/query/framework_control.cpp +++ b/src/mongo/db/query/framework_control.cpp @@ -29,6 +29,8 @@ #include "mongo/platform/basic.h" +#include "mongo/db/commands/test_commands_enabled.h" +#include "mongo/db/query/query_feature_flags_gen.h" #include "mongo/db/query/query_knobs_gen.h" namespace mongo { @@ -41,7 +43,43 @@ void QueryFrameworkControl::append(OperationContext*, } Status QueryFrameworkControl::setFromString(StringData value, const boost::optional<TenantId>&) { - _data = QueryFrameworkControl_parse(IDLParserContext("internalQueryFrameworkControl"), value); + auto newVal = + QueryFrameworkControl_parse(IDLParserContext("internalQueryFrameworkControl"), value); + + // To enable Bonsai, the feature flag must be enabled. Here, we return an error to the user if + // they try to set the framework control knob to use Bonsai while the feature flag is disabled. + // + // Note that we only check if the feature flag is enabled ignoring FCV. If, for example, the FCV + // is not initialized, then we don't want to fail here. + // + // The feature flag should be initialized by this point because + // server_options_detail::applySetParameterOptions(std::map ...) + // handles setParameters in alphabetical order, so "feature" comes before "internal". + + // (Ignore FCV check): This is intentional because we always want to use this feature once the + // feature flag is enabled. + bool enabledWithoutFCV = + feature_flags::gFeatureFlagCommonQueryFramework.isEnabledAndIgnoreFCVUnsafe(); + switch (newVal) { + case QueryFrameworkControlEnum::kForceClassicEngine: + case QueryFrameworkControlEnum::kTrySbeEngine: + break; + case QueryFrameworkControlEnum::kTryBonsai: + if (enabledWithoutFCV) { + break; + } + return {ErrorCodes::IllegalOperation, + "featureFlagCommonQueryFramework must be enabled to run with tryBonsai"}; + case QueryFrameworkControlEnum::kForceBonsai: + if (enabledWithoutFCV && getTestCommandsEnabled()) { + break; + } + return {ErrorCodes::IllegalOperation, + "featureFlagCommonQueryFramework and testCommands must be enabled to run with " + "forceBonsai"}; + } + + _data = std::move(newVal); return Status::OK(); } |