summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2015-09-09 13:18:41 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2015-09-10 16:18:43 -0400
commitc4f421ecb0b64a52f8b1e4dd6b617a83f7d24274 (patch)
tree1aef5eb493f03ef255af131d648094c04b0be0c6
parent5dbcd42903ceb92bdaa651d6ad60a5200188872e (diff)
downloadmongo-c4f421ecb0b64a52f8b1e4dd6b617a83f7d24274.tar.gz
SERVER-18384 Check concurrent election in signalPrimaryUnavailable.
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index a1cf1a49d25..eb03b42098a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -1607,6 +1607,12 @@ void ReplicationCoordinatorImpl::processReplSetMetadata(const rpc::ReplSetMetada
void ReplicationCoordinatorImpl::signalPrimaryUnavailable() {
auto work = [this](const CallbackArgs&) {
+ // We may have learned that the primary is down in heartbeat.
+ // TODO(siyuan) Clean up this code/comment after we only allow timer-based election.
+ if (_topCoord->getRole() != TopologyCoordinator::Role::follower) {
+ return;
+ }
+
_topCoord->setPrimaryIndex(-1);
if (_topCoord->checkShouldStandForElection(_replExecutor.now(), getMyLastOptime())) {
_startElectSelfV1();