From fccad833c9081bf0cd61364afdb4ec01ceeb42fa Mon Sep 17 00:00:00 2001 From: Wenbin Zhu Date: Tue, 2 Mar 2021 23:43:37 +0000 Subject: [PATCH] SERVER-53428 Add initial sync result status in statistics. --- src/mongo/db/repl/initial_syncer.cpp | 39 +++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index 1a896967971..8de8e05938b 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -1693,10 +1693,6 @@ void InitialSyncer::_finishInitialSyncAttempt(const StatusWith lock(_mutex); - LOGV2(21192, - "Initial Sync Attempt Statistics: {statistics}", - "Initial Sync Attempt Statistics", - "statistics"_attr = redact(_getInitialSyncProgress_inlock())); auto runTime = _initialSyncState ? _initialSyncState->timer.millis() : 0; int rollBackId = -1; @@ -1710,6 +1706,12 @@ void InitialSyncer::_finishInitialSyncAttempt(const StatusWith(_sharedData->getTotalTimeUnreachable(sdLock)); } + if (MONGO_unlikely(failAndHangInitialSync.shouldFail())) { + LOGV2(21193, "failAndHangInitialSync fail point enabled"); + failAndHangInitialSync.pauseWhileSet(); + result = Status(ErrorCodes::InternalError, "failAndHangInitialSync fail point enabled"); + } + _stats.initialSyncAttemptInfos.emplace_back( InitialSyncer::InitialSyncAttemptInfo{runTime, result.getStatus(), @@ -1718,25 +1720,27 @@ void InitialSyncer::_finishInitialSyncAttempt(const StatusWith= _stats.maxFailedInitialSyncAttempts) { + if (!hasRetries) { LOGV2_FATAL_CONTINUE(21202, "The maximum number of retries have been exhausted for initial sync"); @@ -1774,7 +1778,6 @@ void InitialSyncer::_finishInitialSyncAttempt(const StatusWith