diff options
author | Spencer T Brody <spencer@mongodb.com> | 2017-09-29 13:25:32 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2017-10-04 12:03:47 -0400 |
commit | d1153c137c6422b7f9333aefaacb536cc664aae5 (patch) | |
tree | 0c55dd3b6fae7a1576a8073c543344e7d3b260cf /src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp | |
parent | 763e9a4a675668ba3c0d3836321f53c77950cc53 (diff) | |
download | mongo-d1153c137c6422b7f9333aefaacb536cc664aae5.tar.gz |
SERVER-31330 Prevent stepdown during drain mode from triggering an invariant
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp index 1b02badec85..84ea786227a 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp @@ -371,7 +371,20 @@ void ReplicationCoordinatorImpl::_stepDownFinish( return; } - MONGO_FAIL_POINT_PAUSE_WHILE_SET(blockHeartbeatStepdown); + if (MONGO_FAIL_POINT(blockHeartbeatStepdown)) { + // This log output is used in js tests so please leave it. + log() << "stepDown - blockHeartbeatStepdown fail point enabled. " + "Blocking until fail point is disabled."; + + auto inShutdown = [&] { + stdx::lock_guard<stdx::mutex> lk(_mutex); + return _inShutdown; + }; + + while (MONGO_FAIL_POINT(blockHeartbeatStepdown) && !inShutdown()) { + mongo::sleepsecs(1); + } + } auto opCtx = cc().makeOperationContext(); Lock::GlobalWrite globalExclusiveLock(opCtx.get()); |