summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl.cpp
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2018-07-26 13:26:46 -0400
committerSuganthi Mani <suganthi.mani@mongodb.com>2018-08-05 20:35:38 -0400
commit68b6e2d22d5ef67d00e83f27a6e0f5b436613a92 (patch)
treefe235c0b13357815927874fd4b13d8d19c362203 /src/mongo/db/repl/replication_coordinator_impl.cpp
parent8175d47cb1d662c46d5e2e19fd3165690916ae18 (diff)
downloadmongo-68b6e2d22d5ef67d00e83f27a6e0f5b436613a92.tar.gz
SERVER-35951 Fix to prevent race between repl set unfreeze and _startElectSelfIfEligibleV1 (election timeout) for pv1 single node replica set case.
(cherry picked from commit 32bd1c03753a5cd349841eea0d5541e1f3f1305d)
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index ea0b52b58ac..c50dcf751a6 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -1782,7 +1782,7 @@ void ReplicationCoordinatorImpl::_handleTimePassing(
// against other elections caused by events like election timeout, replSetStepUp etc.
if (isV1ElectionProtocol()) {
_startElectSelfIfEligibleV1(
- TopologyCoordinator::StartElectionReason::kSingleNodeStepDownTimeout);
+ TopologyCoordinator::StartElectionReason::kSingleNodePromptElection);
return;
}
@@ -2131,11 +2131,12 @@ Status ReplicationCoordinatorImpl::processReplSetFreeze(int secs, BSONObjBuilder
return result.getStatus();
}
- if (TopologyCoordinator::PrepareFreezeResponseResult::kElectSelf == result.getValue()) {
- // If we just unfroze and ended our stepdown period and we are a one node replica set,
- // the topology coordinator will have gone into the candidate role to signal that we
- // need to elect ourself.
- _performPostMemberStateUpdateAction(kActionWinElection);
+ if (TopologyCoordinator::PrepareFreezeResponseResult::kSingleNodeSelfElect ==
+ result.getValue()) {
+ // For election protocol v1, call _startElectSelfIfEligibleV1 to avoid race
+ // against other elections caused by events like election timeout, replSetStepUp etc.
+ _startElectSelfIfEligibleV1(
+ TopologyCoordinator::StartElectionReason::kSingleNodePromptElection);
}
return Status::OK();