summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-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
8 files changed, 54 insertions, 1 deletions
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