diff options
Diffstat (limited to 'src/mongo/db/repl/initial_syncer.cpp')
-rw-r--r-- | src/mongo/db/repl/initial_syncer.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index cab70266214..c56ef6794f0 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -122,6 +122,9 @@ MONGO_FAIL_POINT_DEFINE(initialSyncFassertIfApplyingBatchFails); // Failpoint which causes the initial sync function to hang before stopping the oplog fetcher. MONGO_FAIL_POINT_DEFINE(initialSyncHangBeforeCompletingOplogFetching); +// Failpoint which causes the initial sync function to hang after finishing. +MONGO_FAIL_POINT_DEFINE(initialSyncHangAfterFinish); + // Failpoints for synchronization, shared with cloners. extern FailPoint initialSyncFuzzerSynchronizationPoint1; extern FailPoint initialSyncFuzzerSynchronizationPoint2; @@ -1851,22 +1854,33 @@ void InitialSyncer::_finishCallback(StatusWith<OpTimeAndWallTime> lastApplied, // before InitialSyncer::join() returns. onCompletion = {}; - stdx::lock_guard<Latch> lock(_mutex); - invariant(_state != State::kComplete); - _state = State::kComplete; - _stateCondition.notify_all(); + { + stdx::lock_guard<Latch> lock(_mutex); + invariant(_state != State::kComplete); + _state = State::kComplete; + _stateCondition.notify_all(); - // Clear the initial sync progress after an initial sync attempt has been successfully - // completed. - if (lastApplied.isOK() && !MONGO_unlikely(skipClearInitialSyncState.shouldFail())) { - _initialSyncState.reset(); + // Clear the initial sync progress after an initial sync attempt has been successfully + // completed. + if (lastApplied.isOK() && !MONGO_unlikely(skipClearInitialSyncState.shouldFail())) { + _initialSyncState.reset(); + } + + // Destroy shared references to executors. + _attemptExec = nullptr; + _clonerAttemptExec = nullptr; + _clonerExec = nullptr; + _exec = nullptr; } - // Destroy shared references to executors. - _attemptExec = nullptr; - _clonerAttemptExec = nullptr; - _clonerExec = nullptr; - _exec = nullptr; + if (MONGO_unlikely(initialSyncHangAfterFinish.shouldFail())) { + LOGV2(5825800, + "initial sync finished - initialSyncHangAfterFinish fail point " + "enabled. Blocking until fail point is disabled."); + while (MONGO_unlikely(initialSyncHangAfterFinish.shouldFail()) && !_isShuttingDown()) { + mongo::sleepsecs(1); + } + } } Status InitialSyncer::_scheduleLastOplogEntryFetcher_inlock( |