summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarun Ravichandran <varun.ravichandran@mongodb.com>2022-06-08 14:35:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-08 20:15:11 +0000
commitddc027f204e12c4ad4518736550281f6f07beaf3 (patch)
tree48547c6ed35a144866dce150ea368883ce31d4c0
parent023f0b82b857255968d4e27f3a51ed820ec174ea (diff)
downloadmongo-ddc027f204e12c4ad4518736550281f6f07beaf3.tar.gz
Revert "SERVER-65572: Remove featureFlagClusterWideConfig"
This reverts commit 9508343fa1fc296ac200a6342b8fe974c17ee019.
-rw-r--r--jstests/auth/lib/commands_lib.js4
-rw-r--r--jstests/noPassthrough/change_stream_options.js2
-rw-r--r--jstests/noPassthrough/change_stream_pre_image_time_based_expiration_replset.js2
-rw-r--r--jstests/noPassthrough/change_stream_pre_image_time_based_expiration_sharded.js2
-rw-r--r--jstests/noPassthrough/cluster-server-parameter-op-observer.js4
-rw-r--r--jstests/noPassthrough/cluster_server_parameter_refresher.js3
-rw-r--r--jstests/noPassthrough/disabled_cluster_server_parameters.js3
-rw-r--r--jstests/noPassthrough/set_cluster_parameter_fcv.js109
-rw-r--r--jstests/replsets/cluster_server_parameter_commands_replset.js3
-rw-r--r--jstests/replsets/set_cluster_parameter_replset.js3
-rw-r--r--jstests/sharding/cluster_server_parameter_commands_sharded.js3
-rw-r--r--jstests/sharding/set_cluster_parameter.js3
-rw-r--r--src/mongo/db/commands/get_cluster_parameter_invocation.cpp4
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_command.cpp6
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp24
-rw-r--r--src/mongo/db/mongod_main.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp6
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp2
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp3
-rw-r--r--src/mongo/idl/cluster_server_parameter.idl5
20 files changed, 192 insertions, 4 deletions
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js
index d4941a18b1f..a849f441a44 100644
--- a/jstests/auth/lib/commands_lib.js
+++ b/jstests/auth/lib/commands_lib.js
@@ -4179,7 +4179,7 @@ var authCommandsLib = {
skipTest: (conn) => {
const hello = assert.commandWorked(conn.getDB("admin").runCommand({hello: 1}));
const isStandalone = hello.msg !== "isdbgrid" && !hello.hasOwnProperty('setName');
- return isStandalone;
+ return !TestData.setParameters.featureFlagClusterWideConfig || isStandalone;
},
testcases: [
{
@@ -5672,7 +5672,7 @@ var authCommandsLib = {
skipTest: (conn) => {
const hello = assert.commandWorked(conn.getDB("admin").runCommand({hello: 1}));
const isStandalone = hello.msg !== "isdbgrid" && !hello.hasOwnProperty('setName');
- return isStandalone;
+ return !TestData.setParameters.featureFlagClusterWideConfig || isStandalone;
},
testcases: [
{
diff --git a/jstests/noPassthrough/change_stream_options.js b/jstests/noPassthrough/change_stream_options.js
index 2a36bb840dd..0366d65bcfb 100644
--- a/jstests/noPassthrough/change_stream_options.js
+++ b/jstests/noPassthrough/change_stream_options.js
@@ -1,6 +1,8 @@
// Tests setClusterParameter and getClusterParameter for changeStreamOptions on standalone, replica
// set and sharded cluster configurations.
// @tags: [
+// requires_fcv_60,
+// featureFlagClusterWideConfig,
// requires_replication,
// requires_sharding,
// ]
diff --git a/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_replset.js b/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_replset.js
index d7af9b045cd..0f50af88ebd 100644
--- a/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_replset.js
+++ b/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_replset.js
@@ -1,5 +1,7 @@
// Tests time-based pre-image retention policy of change stream pre-images remover job.
// @tags: [
+// requires_fcv_60,
+// featureFlagClusterWideConfig,
// requires_replication,
// ]
(function() {
diff --git a/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_sharded.js b/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_sharded.js
index 551ae495b58..399134978c2 100644
--- a/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_sharded.js
+++ b/jstests/noPassthrough/change_stream_pre_image_time_based_expiration_sharded.js
@@ -1,5 +1,7 @@
// Tests time-based pre-image retention policy of change stream pre-images remover job.
// @tags: [
+// requires_fcv_60,
+// featureFlagClusterWideConfig,
// requires_sharding,
// ]
(function() {
diff --git a/jstests/noPassthrough/cluster-server-parameter-op-observer.js b/jstests/noPassthrough/cluster-server-parameter-op-observer.js
index ce8f7dbcb11..b0bc07fee1a 100644
--- a/jstests/noPassthrough/cluster-server-parameter-op-observer.js
+++ b/jstests/noPassthrough/cluster-server-parameter-op-observer.js
@@ -4,6 +4,10 @@
(function() {
'use strict';
+if (!TestData.setParameters.featureFlagClusterWideConfig) {
+ return;
+}
+
const kUnknownCSPLogId = 6226300;
const kUnknownCSPLogComponent = 'control';
const kUnknownCSPLogLevel = 3;
diff --git a/jstests/noPassthrough/cluster_server_parameter_refresher.js b/jstests/noPassthrough/cluster_server_parameter_refresher.js
index 8edc13641eb..a7aaf4cd880 100644
--- a/jstests/noPassthrough/cluster_server_parameter_refresher.js
+++ b/jstests/noPassthrough/cluster_server_parameter_refresher.js
@@ -2,8 +2,9 @@
* Checks that the mongos cluster server parameter refresh job runs as expected.
*
* @tags: [
- * # Requires all nodes to be running at least 6.1.
+ * # Requires all nodes to be running the latest binary.
* requires_fcv_61,
+ * featureFlagClusterWideConfig,
* featureFlagClusterWideConfigM2,
* does_not_support_stepdowns,
* requires_replication,
diff --git a/jstests/noPassthrough/disabled_cluster_server_parameters.js b/jstests/noPassthrough/disabled_cluster_server_parameters.js
index 5e160a139b1..e2da17b49c5 100644
--- a/jstests/noPassthrough/disabled_cluster_server_parameters.js
+++ b/jstests/noPassthrough/disabled_cluster_server_parameters.js
@@ -3,6 +3,9 @@
* is false.
*
* @tags: [
+ * # Requires all nodes to be running the latest binary.
+ * requires_fcv_60,
+ * featureFlagClusterWideConfig,
* does_not_support_stepdowns,
* requires_replication,
* requires_sharding
diff --git a/jstests/noPassthrough/set_cluster_parameter_fcv.js b/jstests/noPassthrough/set_cluster_parameter_fcv.js
new file mode 100644
index 00000000000..3b9075e1d53
--- /dev/null
+++ b/jstests/noPassthrough/set_cluster_parameter_fcv.js
@@ -0,0 +1,109 @@
+// Test setClusterParameter command against FCV.
+//
+// @tags: [
+// creates_and_authenticates_user,
+// requires_auth,
+// requires_fcv_60,
+// requires_non_retryable_commands,
+// requires_persistence,
+// requires_replication,
+// disabled_for_fcv_6_1_upgrade,
+// ]
+
+load("jstests/noPassthrough/libs/user_write_blocking.js");
+
+(function() {
+'use strict';
+
+const {
+ WriteBlockState,
+ ShardingFixture,
+ ReplicaFixture,
+ bypassUser,
+ noBypassUser,
+ password,
+ keyfile
+} = UserWriteBlockHelpers;
+
+function mapToClusterParamsColl(db) {
+ return db.getSiblingDB('config').clusterParameters;
+}
+
+function runTest(fixture) {
+ // When the cluster is started at FCV 6.0, it is possible to run setClusterParameter.
+ fixture.asAdmin(({admin}) => assert.commandWorked(admin.runCommand(
+ {setClusterParameter: {testIntClusterParameter: {intData: 102}}})));
+
+ // Check that the config.clusterParameters collection has been created with a document for the
+ // parameter.
+ fixture.asAdmin(
+ ({db}) => assert.eq(1, mapToClusterParamsColl(db).count({_id: "testIntClusterParameter"})));
+
+ // When the cluster is at FCV 6.0 without an ongoing setClusterParameter operation in progress,
+ // it should be possible to downgrade the cluster.
+ fixture.asAdmin(({admin}) => assert.commandWorked(
+ admin.runCommand({setFeatureCompatibilityVersion: "5.0"})));
+
+ // After downgrade, config.clusterParameters should not exist.
+ fixture.asAdmin(({db}) => assert.isnull(mapToClusterParamsColl(db).exists()));
+ fixture.asAdmin(
+ ({db}) => assert.eq(
+ 0, mapToClusterParamsColl(db).count({_id: "testIntClusterParameter", intData: 102})));
+
+ // While the cluster is downgraded, it should not be possible to run setClusterParameter.
+ fixture.asAdmin(({admin}) => assert.commandFailed(admin.runCommand(
+ {setClusterParameter: {testIntClusterParameter: {intData: 102}}})));
+
+ // Upgrading the cluster back to 6.0 should permit setClusterParameter to work again.
+ fixture.asAdmin(({admin}) => assert.commandWorked(
+ admin.runCommand({setFeatureCompatibilityVersion: "6.0"})));
+ fixture.asAdmin(({admin}) => assert.commandWorked(admin.runCommand(
+ {setClusterParameter: {testIntClusterParameter: {intData: 103}}})));
+
+ // Set a failpoint to make setClusterParameter hang on a sharded cluster. FCV downgrade should
+ // fail while setClusterParameter is in progress.
+ if (fixture.hangTransition) {
+ let hangWaiter =
+ fixture.hangTransition({setClusterParameter: {testIntClusterParameter: {intData: 105}}},
+ 'hangInShardsvrSetClusterParameter');
+
+ fixture.asAdmin(({admin}) => assert.commandFailedWithCode(
+ admin.runCommand({setFeatureCompatibilityVersion: "5.0"}),
+ ErrorCodes.CannotDowngrade));
+
+ // Restart the config server primary and verify that FCV downgrade still fails.
+ fixture.restartConfigPrimary();
+ fixture.asAdmin(({admin}) => assert.commandFailedWithCode(
+ admin.runCommand({setFeatureCompatibilityVersion: "5.0"}),
+ ErrorCodes.CannotDowngrade));
+
+ // Turn off the failpoint and wait for the hung setClusterParameter operation to drain.
+ hangWaiter.failpoint.off();
+ hangWaiter.waiter();
+
+ // Verify that the updated value was successfully updated and is visible despite the restart
+ // and failed FCV downgrade attempts.
+ fixture.asAdmin(({admin}) => assert.eq(
+ 105,
+ admin.runCommand({getClusterParameter: "testIntClusterParameter"})
+ .clusterParameters[0]
+ .intData));
+
+ // Verify that FCV downgrade succeeds after the setClusterParameter operation has drained.
+ fixture.asAdmin(({admin}) => assert.commandWorked(
+ admin.runCommand({setFeatureCompatibilityVersion: "5.0"})));
+ }
+}
+
+{
+ const rst = new ReplicaFixture();
+ runTest(rst);
+ rst.stop();
+}
+
+{
+ const st = new ShardingFixture();
+ runTest(st);
+ st.stop();
+}
+}());
diff --git a/jstests/replsets/cluster_server_parameter_commands_replset.js b/jstests/replsets/cluster_server_parameter_commands_replset.js
index ccf809765fa..7c780307561 100644
--- a/jstests/replsets/cluster_server_parameter_commands_replset.js
+++ b/jstests/replsets/cluster_server_parameter_commands_replset.js
@@ -2,6 +2,9 @@
* Checks that set/getClusterParameter runs as expected on replica set nodes.
*
* @tags: [
+ * # Requires all nodes to be running the latest binary.
+ * requires_fcv_60,
+ * featureFlagClusterWideConfig,
* does_not_support_stepdowns,
* requires_replication
* ]
diff --git a/jstests/replsets/set_cluster_parameter_replset.js b/jstests/replsets/set_cluster_parameter_replset.js
index 65beea7ad70..a9469c0aa06 100644
--- a/jstests/replsets/set_cluster_parameter_replset.js
+++ b/jstests/replsets/set_cluster_parameter_replset.js
@@ -3,6 +3,9 @@
*
* @tags: [
* does_not_support_stepdowns,
+ * featureFlagClusterWideConfig,
+ * # Requires all nodes to be running the latest binary.
+ * requires_fcv_60,
* # Restarts all replica set member nodes mid-test.
* requires_persistence,
* ]
diff --git a/jstests/sharding/cluster_server_parameter_commands_sharded.js b/jstests/sharding/cluster_server_parameter_commands_sharded.js
index 0b1c0a47c3b..4b8486befc9 100644
--- a/jstests/sharding/cluster_server_parameter_commands_sharded.js
+++ b/jstests/sharding/cluster_server_parameter_commands_sharded.js
@@ -2,6 +2,9 @@
* Checks that set/getClusterParameter runs as expected on sharded clusters.
*
* @tags: [
+ * # Requires all nodes to be running the latest binary.
+ * requires_fcv_60,
+ * featureFlagClusterWideConfig,
* does_not_support_stepdowns,
* requires_replication,
* requires_sharding
diff --git a/jstests/sharding/set_cluster_parameter.js b/jstests/sharding/set_cluster_parameter.js
index 754245b02df..5ee591831a9 100644
--- a/jstests/sharding/set_cluster_parameter.js
+++ b/jstests/sharding/set_cluster_parameter.js
@@ -5,6 +5,9 @@
* inMemory variants
*
* @tags: [
+ * # Requires all nodes to be running the latest binary.
+ * requires_fcv_60,
+ * featureFlagClusterWideConfig,
* does_not_support_stepdowns,
* requires_persistence,
* ]
diff --git a/src/mongo/db/commands/get_cluster_parameter_invocation.cpp b/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
index 7eb4218040e..b95acf4896f 100644
--- a/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
+++ b/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
@@ -43,6 +43,10 @@ namespace mongo {
std::pair<std::vector<std::string>, std::vector<BSONObj>>
GetClusterParameterInvocation::retrieveRequestedParameters(OperationContext* opCtx,
const CmdBody& cmdBody) {
+ uassert(ErrorCodes::IllegalOperation,
+ "featureFlagClusterWideConfig not enabled",
+ gFeatureFlagClusterWideConfig.isEnabled(serverGlobalParams.featureCompatibility));
+
ServerParameterSet* clusterParameters = ServerParameterSet::getClusterParameterSet();
std::vector<std::string> parameterNames;
std::vector<BSONObj> parameterValues;
diff --git a/src/mongo/db/commands/set_cluster_parameter_command.cpp b/src/mongo/db/commands/set_cluster_parameter_command.cpp
index 08ae1b2835e..696c6eda751 100644
--- a/src/mongo/db/commands/set_cluster_parameter_command.cpp
+++ b/src/mongo/db/commands/set_cluster_parameter_command.cpp
@@ -75,6 +75,12 @@ public:
"setClusterParameter can only run on mongos in sharded clusters",
(serverGlobalParams.clusterRole == ClusterRole::None));
+ FixedFCVRegion fcvRegion(opCtx);
+ uassert(
+ ErrorCodes::IllegalOperation,
+ "Cannot set cluster parameter, gFeatureFlagClusterWideConfig is not enabled",
+ gFeatureFlagClusterWideConfig.isEnabled(serverGlobalParams.featureCompatibility));
+
// TODO SERVER-65249: This will eventually be made specific to the parameter being set
// so that some parameters will be able to use setClusterParameter even on standalones.
uassert(ErrorCodes::IllegalOperation,
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index e9884a73b8a..ce21bce9a13 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -388,6 +388,30 @@ public:
!isBlockingUserWrites);
}
+ // TODO (SERVER-65572): Remove setClusterParameter serialization and collection
+ // drop after this is backported to 6.0.
+ if (!gFeatureFlagClusterWideConfig.isEnabledOnVersion(requestedVersion)) {
+ if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) {
+ uassert(ErrorCodes::CannotDowngrade,
+ "Cannot downgrade while cluster server parameter is being set",
+ ConfigsvrCoordinatorService::getService(opCtx)
+ ->areAllCoordinatorsOfTypeFinished(
+ opCtx, ConfigsvrCoordinatorTypeEnum::kSetClusterParameter));
+ }
+
+ DropReply dropReply;
+ const auto dropStatus = dropCollection(
+ opCtx,
+ NamespaceString::kClusterParametersNamespace,
+ &dropReply,
+ DropCollectionSystemCollectionMode::kAllowSystemCollectionDrops);
+ uassert(
+ dropStatus.code(),
+ str::stream() << "Failed to drop the cluster server parameters collection"
+ << causedBy(dropStatus.reason()),
+ dropStatus.isOK() || dropStatus.code() == ErrorCodes::NamespaceNotFound);
+ }
+
FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument(
opCtx,
actualVersion,
diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp
index 21474850bed..ccb5ce1a404 100644
--- a/src/mongo/db/mongod_main.cpp
+++ b/src/mongo/db/mongod_main.cpp
@@ -1144,7 +1144,10 @@ void setUpObservers(ServiceContext* serviceContext) {
opObserverRegistry->addObserver(
std::make_unique<repl::PrimaryOnlyServiceOpObserver>(serviceContext));
opObserverRegistry->addObserver(std::make_unique<FcvOpObserver>());
- opObserverRegistry->addObserver(std::make_unique<ClusterServerParameterOpObserver>());
+
+ if (gFeatureFlagClusterWideConfig.isEnabledAndIgnoreFCV()) {
+ opObserverRegistry->addObserver(std::make_unique<ClusterServerParameterOpObserver>());
+ }
setupFreeMonitoringOpObserver(opObserverRegistry.get());
diff --git a/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp b/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp
index 3b2a6c883df..31a20120586 100644
--- a/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp
+++ b/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp
@@ -62,6 +62,12 @@ public:
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
const auto coordinatorCompletionFuture = [&]() -> SharedSemiFuture<void> {
+ FixedFCVRegion fcvRegion(opCtx);
+ uassert(ErrorCodes::IllegalOperation,
+ "featureFlagClusterWideConfig not enabled",
+ gFeatureFlagClusterWideConfig.isEnabled(
+ serverGlobalParams.featureCompatibility));
+
// Validate parameter before creating coordinator.
{
BSONObj cmdParamObj = request().getCommandParameter();
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
index bfef69bcb9f..0a45a9d3a6d 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
@@ -175,6 +175,8 @@ protected:
}
void expectClusterParametersRequest(const HostAndPort& target) {
+ if (!gFeatureFlagClusterWideConfig.isEnabled(serverGlobalParams.featureCompatibility))
+ return;
auto clusterParameterDocs = uassertStatusOK(getConfigShard()->exhaustiveFindOnConfig(
operationContext(),
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
index 947ec9fb3c2..7de1d4c3efe 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
@@ -1201,6 +1201,9 @@ void ShardingCatalogManager::_pushClusterParametersToNewShard(
void ShardingCatalogManager::_standardizeClusterParameters(OperationContext* opCtx,
RemoteCommandTargeter* targeter) {
+ if (!gFeatureFlagClusterWideConfig.isEnabled(serverGlobalParams.featureCompatibility))
+ return;
+
auto clusterParameterDocs =
uassertStatusOK(Grid::get(opCtx)->shardRegistry()->getConfigShard()->exhaustiveFindOnConfig(
opCtx,
diff --git a/src/mongo/idl/cluster_server_parameter.idl b/src/mongo/idl/cluster_server_parameter.idl
index 14622beeae0..9d99717cba5 100644
--- a/src/mongo/idl/cluster_server_parameter.idl
+++ b/src/mongo/idl/cluster_server_parameter.idl
@@ -87,6 +87,11 @@ structs:
default: 0
feature_flags:
+ featureFlagClusterWideConfig:
+ description: Mechanism for cluster-wide configuration options
+ cpp_varname: gFeatureFlagClusterWideConfig
+ default: true
+ version: 6.0
featureFlagClusterWideConfigM2:
description: Mechanism for cluster-wide configuration options, milestone 2
cpp_varname: gFeatureFlagClusterWideConfigM2