diff options
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/repl_server_parameters.idl | 10 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator.cpp | 12 |
3 files changed, 18 insertions, 5 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index dadd94cb10d..cda28665b2e 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -667,6 +667,7 @@ env.Library('topology_coordinator', LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/catalog/commit_quorum_options', '$BUILD_DIR/mongo/idl/server_parameter', + 'repl_server_parameters' ]) env.Library( diff --git a/src/mongo/db/repl/repl_server_parameters.idl b/src/mongo/db/repl/repl_server_parameters.idl index befa9891c42..2e06b7101f7 100644 --- a/src/mongo/db/repl/repl_server_parameters.idl +++ b/src/mongo/db/repl/repl_server_parameters.idl @@ -307,6 +307,16 @@ server_parameters: cpp_varname: assertStableTimestampEqualsAppliedThroughOnRecovery default: false + enableOverrideClusterChainingSetting: + description: >- + When enabled, allows a node to override the cluster-wide chainingAllowed setting. + If chaining is disabled in the replica set, enabling this parameter allows the node + to chain regardless. + set_at: [ startup ] + cpp_vartype: AtomicWord<bool> + cpp_varname: enableOverrideClusterChainingSetting + default: false + startupRecoveryForRestore: description: >- When set, do startup recovery in such a way that the history of the recovered diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp index ea679f51ba0..6dd1b2d6117 100644 --- a/src/mongo/db/repl/topology_coordinator.cpp +++ b/src/mongo/db/repl/topology_coordinator.cpp @@ -55,6 +55,7 @@ #include "mongo/db/repl/heartbeat_response_action.h" #include "mongo/db/repl/isself.h" #include "mongo/db/repl/member_data.h" +#include "mongo/db/repl/repl_server_parameters_gen.h" #include "mongo/logv2/log.h" #include "mongo/rpc/metadata/oplog_query_metadata.h" #include "mongo/rpc/metadata/repl_set_metadata.h" @@ -213,7 +214,7 @@ HostAndPort TopologyCoordinator::chooseNewSyncSource(Date_t now, // If we are only allowed to sync from the primary, use it as the sync source if possible. if (readPreference == ReadPreference::PrimaryOnly || (chainingPreference == ChainingPreference::kUseConfiguration && - !_rsConfig.isChainingAllowed())) { + !_rsConfig.isChainingAllowed() && !enableOverrideClusterChainingSetting.load())) { if (readPreference == ReadPreference::SecondaryOnly) { LOGV2_FATAL( 3873102, @@ -2951,10 +2952,11 @@ bool TopologyCoordinator::shouldChangeSyncSource(const HostAndPort& currentSourc bool sourceIsPrimary = replMetadata.getIsPrimary().value_or(oqMetadata.getPrimaryIndex() == currentSourceIndex); - // Change sync source if chaining is disabled, we are not syncing from the primary, and we know - // who the new primary is. We do not consider chaining disabled if we are the primary, since - // we are in catchup mode. - auto chainingDisabled = !_rsConfig.isChainingAllowed() && _currentPrimaryIndex != _selfIndex; + // Change sync source if chaining is disabled (without overrides), we are not syncing from the + // primary, and we know who the new primary is. We do not consider chaining disabled if we are + // the primary, since we are in catchup mode. + auto chainingDisabled = !_rsConfig.isChainingAllowed() && + !enableOverrideClusterChainingSetting.load() && _currentPrimaryIndex != _selfIndex; auto foundNewPrimary = _currentPrimaryIndex != -1 && _currentPrimaryIndex != currentSourceIndex; if (!sourceIsPrimary && chainingDisabled && foundNewPrimary) { auto newPrimary = _rsConfig.getMemberAt(_currentPrimaryIndex).getHostAndPort(); |