summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp67
1 files changed, 18 insertions, 49 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index f63f9b90ece..69b769e0cc6 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -3467,57 +3467,26 @@ Status ReplicationCoordinatorImpl::_doReplSetReconfig(OperationContext* opCtx,
return status;
ReplSetConfig newConfig = newConfigStatus.getValue();
- // Excluding reconfigs that bump the config term during step-up from checking against changing
- // the implicit default write concern, as it is not needed.
- if (!skipSafetyChecks /* skipping step-up reconfig */) {
+ // If the new config changes the replica set's implicit default write concern, we fail the
+ // reconfig command. This includes force reconfigs, but excludes reconfigs that bump the config
+ // term during step-up. The user should set a cluster-wide write concern and attempt the
+ // reconfig command again. We also need to exclude shard servers from this validation, as shard
+ // servers don't store the cluster-wide write concern.
+ if (!skipSafetyChecks /* skipping step-up reconfig */ &&
+ repl::feature_flags::gDefaultWCMajority.isEnabled(
+ serverGlobalParams.featureCompatibility) &&
+ serverGlobalParams.clusterRole != ClusterRole::ShardServer &&
+ !repl::enableDefaultWriteConcernUpdatesForInitiate.load()) {
bool currIDWC = oldConfig.isImplicitDefaultWriteConcernMajority();
bool newIDWC = newConfig.isImplicitDefaultWriteConcernMajority();
-
- // If the new config changes the replica set's implicit default write concern, we fail the
- // reconfig command. This includes force reconfigs.
- // The user should set a cluster-wide write concern and attempt the reconfig command again.
- if (serverGlobalParams.clusterRole != ClusterRole::ShardServer) {
- if (repl::feature_flags::gDefaultWCMajority.isEnabled(
- serverGlobalParams.featureCompatibility) &&
- !repl::enableDefaultWriteConcernUpdatesForInitiate.load() && currIDWC != newIDWC &&
- !ReadWriteConcernDefaults::get(opCtx).isCWWCSet(opCtx)) {
- return Status(
- ErrorCodes::NewReplicaSetConfigurationIncompatible,
- str::stream()
- << "Reconfig attempted to install a config that would change the implicit "
- "default write concern. Use the setDefaultRWConcern command to set a "
- "cluster-wide write concern and try the reconfig again.");
- }
- } else {
- // Allow all reconfigs if the shard is not part of a sharded cluster yet, however
- // prevent changing the implicit default write concern to (w: 1) after it becomes part
- // of a sharded cluster and CWWC is not set on the cluster.
- // Remote call to the configServer should be done to check if CWWC is set on the
- // cluster.
- if (_externalState->isShardPartOfShardedCluster(opCtx) && currIDWC != newIDWC &&
- !newIDWC) {
- try {
- // Initiates a remote call to the config server.
- if (!_externalState->isCWWCSetOnConfigShard(opCtx)) {
- return Status(
- ErrorCodes::NewReplicaSetConfigurationIncompatible,
- str::stream()
- << "Reconfig attempted to install a config that would change the "
- "implicit default write concern on the shard to {w: 1}. Use the "
- "setDefaultRWConcern command to set a cluster-wide write "
- "concern on the cluster and try the reconfig again.");
- }
- } catch (const DBException& ex) {
- return Status(
- ErrorCodes::ConfigServerUnreachable,
- str::stream()
- << "Reconfig attempted to install a config that would change the "
- "implicit default write concern on the shard to {w: 1}, but the "
- "shard can not check if CWWC is set on the cluster, as the request "
- "to the config server is failing with error: " +
- ex.toString());
- }
- }
+ bool isCWWCSet = ReadWriteConcernDefaults::get(opCtx).isCWWCSet(opCtx);
+ if (!isCWWCSet && currIDWC != newIDWC) {
+ return Status(
+ ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ str::stream()
+ << "Reconfig attempted to install a config that would change the "
+ "implicit default write concern. Use the setDefaultRWConcern command to "
+ "set a cluster-wide write concern and try the reconfig again.");
}
}