summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/topology_coordinator.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/repl/topology_coordinator.cpp
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/repl/topology_coordinator.cpp')
-rw-r--r--src/mongo/db/repl/topology_coordinator.cpp86
1 files changed, 14 insertions, 72 deletions
diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp
index 630fefa541c..47a043e093e 100644
--- a/src/mongo/db/repl/topology_coordinator.cpp
+++ b/src/mongo/db/repl/topology_coordinator.cpp
@@ -267,23 +267,8 @@ void TopologyCoordinator::_setSyncSource(HostAndPort newSyncSource,
HostAndPort TopologyCoordinator::chooseNewSyncSource(Date_t now,
const OpTime& lastOpTimeFetched,
ReadPreference readPreference) {
- // If we are not a member of the current replica set configuration, no sync source is valid.
- if (_selfIndex == -1) {
- LOGV2_DEBUG(
- 21778, 1, "Cannot sync from any members because we are not in the replica set config");
- return HostAndPort();
- }
-
- // Check to see if we should choose a sync source because 'unsupportedSyncSource' was
- // set.
- auto maybeSyncSource = _chooseSyncSourceUnsupportedSyncSourceParameter(now);
- if (maybeSyncSource) {
- _setSyncSource(*maybeSyncSource, now, false /* fromReplSetSyncFrom */);
- return _syncSource;
- }
-
// Check to see if we should choose a sync source because the 'replSetSyncFrom' command was set.
- maybeSyncSource = _chooseSyncSourceReplSetSyncFrom(now);
+ auto maybeSyncSource = _chooseSyncSourceReplSetSyncFrom(now);
if (maybeSyncSource) {
// If we have a forced sync source via 'replSetSyncFrom', set the _replSetSyncFromSet flag
// to true.
@@ -541,7 +526,9 @@ bool TopologyCoordinator::_isEligibleSyncSource(int candidateIndex,
}
boost::optional<HostAndPort> TopologyCoordinator::_chooseSyncSourceReplSetSyncFrom(Date_t now) {
- invariant(_selfIndex != -1, "Unexpectedly not in the replica set config");
+ if (_selfIndex == -1) {
+ return boost::none;
+ }
if (_forceSyncSourceIndex == -1) {
return boost::none;
@@ -557,43 +544,13 @@ boost::optional<HostAndPort> TopologyCoordinator::_chooseSyncSourceReplSetSyncFr
return syncSource;
}
-boost::optional<HostAndPort> TopologyCoordinator::_chooseSyncSourceUnsupportedSyncSourceParameter(
- Date_t now) {
- invariant(_selfIndex != -1, "Unexpectedly not in the replica set config");
-
- auto syncSourceStr = repl::unsupportedSyncSource;
- if (syncSourceStr.empty()) {
- return boost::none;
- }
- auto syncSource = HostAndPort(syncSourceStr);
- const int syncSourceIndex = _rsConfig.findMemberIndexByHostAndPort(syncSource);
- if (syncSourceIndex < 0) {
- LOGV2_FATAL(
- 7785600,
- "Selecting node specified in 'unsupportedSyncSource' parameter failed due to host "
- "and port not in replica set config.",
- "unsupportedSyncSource"_attr = syncSourceStr);
- }
-
- if (_selfIndex == syncSourceIndex) {
- LOGV2_FATAL(
- 7785601,
- "Node specified in 'unsupportedSyncSource' parameter is self: cannot select self as "
- "a sync source",
- "unsupportedSyncSource"_attr = syncSourceStr);
- }
-
- LOGV2(7785602,
- "Choosing sync source candidate specified by 'unsupportedSyncSource' parameter",
- "syncSource"_attr = syncSourceStr,
- "syncsourceobj"_attr = syncSource);
- std::string msg(str::stream() << "syncing from: " << syncSourceStr << " by request");
- setMyHeartbeatMessage(now, msg);
- return syncSource;
-}
-
boost::optional<HostAndPort> TopologyCoordinator::_chooseSyncSourceInitialChecks(Date_t now) {
- invariant(_selfIndex != -1, "Unexpectedly not in the replica set config");
+ // If we are not a member of the current replica set configuration, no sync source is valid.
+ if (_selfIndex == -1) {
+ LOGV2_DEBUG(
+ 21778, 1, "Cannot sync from any members because we are not in the replica set config");
+ return HostAndPort();
+ }
if (auto sfp = forceSyncSourceCandidate.scoped(); MONGO_unlikely(sfp.isActive())) {
const auto& data = sfp.getData();
@@ -748,13 +705,6 @@ void TopologyCoordinator::prepareSyncFromResponse(const HostAndPort& target,
return;
}
- if (!repl::unsupportedSyncSource.empty()) {
- *result =
- Status(ErrorCodes::IllegalOperation,
- "replSetSyncFrom may not be used when 'unsupportedSyncSource' parameter is set");
- return;
- }
-
ReplSetConfig::MemberIterator targetConfig = _rsConfig.membersEnd();
int targetIndex = 0;
for (ReplSetConfig::MemberIterator it = _rsConfig.membersBegin(); it != _rsConfig.membersEnd();
@@ -3161,13 +3111,6 @@ TopologyCoordinator::_shouldChangeSyncSourceInitialChecks(const HostAndPort& cur
return {ChangeSyncSourceDecision::kNo, -1};
}
- if (!repl::unsupportedSyncSource.empty()) {
- LOGV2(7785604,
- "Not choosing new sync source because sync source is forced via "
- "'unsupportedSyncSource' parameter");
- return {ChangeSyncSourceDecision::kNo, -1};
- }
-
// If the user requested a sync source change, return kYes.
if (_forceSyncSourceIndex != -1) {
LOGV2(21829,
@@ -3361,11 +3304,10 @@ bool TopologyCoordinator::shouldChangeSyncSourceDueToPingTime(const HostAndPort&
// If we find an eligible sync source that is significantly closer than our current sync source,
// return true.
- // Do not re-evaluate our sync source if it was set via the replSetSyncFrom command, the
- // forceSyncSourceCandidate failpoint, or the 'unsupportedSyncSource' server parameter.
+ // Do not re-evaluate our sync source if it was set via the replSetSyncFrom command or the
+ // forceSyncSourceCandidate failpoint.
auto sfp = forceSyncSourceCandidate.scoped();
- if (_replSetSyncFromSet || MONGO_unlikely(sfp.isActive()) ||
- !repl::unsupportedSyncSource.empty()) {
+ if (_replSetSyncFromSet || MONGO_unlikely(sfp.isActive())) {
return false;
}
@@ -3543,7 +3485,7 @@ void TopologyCoordinator::processReplSetRequestVotes(const ReplSetRequestVotesAr
if (!args.isADryRun()) {
_lastVote.setTerm(args.getTerm());
_lastVote.setCandidateIndex(args.getCandidateIndex());
- LOGV2_DEBUG(5972100, 1, "Voting yes in election");
+ LOGV2_DEBUG(5972100, 0, "Voting yes in election");
}
response->setVoteGranted(true);
}