diff options
author | Matthew Russotto <matthew.russotto@mongodb.com> | 2020-01-14 22:58:39 +0000 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-01-27 15:40:33 -0500 |
commit | 93586b0b07cbcda28e3e71504581cba273f07ac8 (patch) | |
tree | 79bcd0ed3e20b2d99b17f639430d14f715d34e0d | |
parent | 9d0de57c33658e67f47eeab07308436a2c3085bc (diff) | |
download | mongo-93586b0b07cbcda28e3e71504581cba273f07ac8.tar.gz |
SERVER-45115 Eliminate circular resource dependency between ReplicationCoordinatorImpl and InitialSyncer.
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 0df5af41967..28578e2f2d0 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -2640,15 +2640,16 @@ Status ReplicationCoordinatorImpl::processReplSetSyncFrom(OperationContext* opCt const HostAndPort& target, BSONObjBuilder* resultObj) { Status result(ErrorCodes::InternalError, "didn't set status in prepareSyncFromResponse"); - auto doResync = false; + std::shared_ptr<InitialSyncer> initialSyncerCopy; { stdx::lock_guard<Latch> lk(_mutex); _topCoord->prepareSyncFromResponse(target, resultObj, &result); - // If we are in the middle of an initial sync, do a resync. - doResync = result.isOK() && _initialSyncer && _initialSyncer->isActive(); + // _initialSyncer must not be called with repl mutex held. + initialSyncerCopy = _initialSyncer; } - if (doResync) { + // If we are in the middle of an initial sync, do a resync. + if (result.isOK() && initialSyncerCopy && initialSyncerCopy->isActive()) { return resyncData(opCtx, false); } |