diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2015-09-09 13:18:41 -0400 |
---|---|---|
committer | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2015-09-10 16:18:43 -0400 |
commit | c4f421ecb0b64a52f8b1e4dd6b617a83f7d24274 (patch) | |
tree | 1aef5eb493f03ef255af131d648094c04b0be0c6 | |
parent | 5dbcd42903ceb92bdaa651d6ad60a5200188872e (diff) | |
download | mongo-c4f421ecb0b64a52f8b1e4dd6b617a83f7d24274.tar.gz |
SERVER-18384 Check concurrent election in signalPrimaryUnavailable.
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 6 |
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(); |