diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2019-01-15 06:41:23 -0500 |
---|---|---|
committer | Suganthi Mani <suganthi.mani@mongodb.com> | 2019-01-23 09:05:58 -0500 |
commit | 55d6072f0be597e950809d9ebcf9ba16cc96942d (patch) | |
tree | 46beb62563e7a2c4ef9b704123c4a540b820b5e3 /src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp | |
parent | b89d1cb056f82af22a5bef211bd2680f3784e7c2 (diff) | |
download | mongo-55d6072f0be597e950809d9ebcf9ba16cc96942d.tar.gz |
SERVER-38511 Avoid killing read operations on stepdown, gated by new server parameter “closeConnectionsOnStepdown”.
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, 11 insertions, 4 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp index fa53cec63ba..39bd6cceffa 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp @@ -384,10 +384,17 @@ void ReplicationCoordinatorImpl::_stepDownFinish( ReplicationStateTransitionLockGuard rstlLock( opCtx.get(), ReplicationStateTransitionLockGuard::EnqueueOnly()); - // Since we are in stepdown, after enqueueing the RSTL we need to kill all user operations to - // ensure that operations that are no longer safe to run (like writes) get killed. - _killOperationsOnStepDown(opCtx.get()); - rstlLock.waitForLockUntil(Date_t::max()); + + // kill all write operations which are no longer safe to run on step down. Also, operations that + // have taken global lock in S mode will be killed to avoid 3-way deadlock between read, + // prepared transaction and step down thread. + KillOpContainer koc(this, opCtx.get()); + koc.startKillOpThread(); + + { + auto rstlOnErrorGuard = makeGuard([&koc] { koc.stopAndWaitForKillOpThread(); }); + rstlLock.waitForLockUntil(Date_t::max()); + } stdx::unique_lock<stdx::mutex> lk(_mutex); |