diff options
Diffstat (limited to 'src/mongo/db/repl/base_cloner.cpp')
-rw-r--r-- | src/mongo/db/repl/base_cloner.cpp | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/src/mongo/db/repl/base_cloner.cpp b/src/mongo/db/repl/base_cloner.cpp index 68411039509..99b38605c4f 100644 --- a/src/mongo/db/repl/base_cloner.cpp +++ b/src/mongo/db/repl/base_cloner.cpp @@ -32,6 +32,7 @@ #include "mongo/platform/basic.h" #include "mongo/db/repl/base_cloner.h" +#include "mongo/logv2/log.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" @@ -91,8 +92,10 @@ Status BaseCloner::run() { } stdx::lock_guard<InitialSyncSharedData> lk(*_sharedData); if (!_sharedData->getInitialSyncStatus(lk).isOK()) { - log() << "Failing data clone because initial sync failed outside data clone: " - << _sharedData->getInitialSyncStatus(lk); + LOGV2(21065, + "Failing data clone because initial sync failed outside data clone: " + "{sharedData_getInitialSyncStatus_lk}", + "sharedData_getInitialSyncStatus_lk"_attr = _sharedData->getInitialSyncStatus(lk)); } return _sharedData->getInitialSyncStatus(lk); } @@ -116,13 +119,14 @@ void BaseCloner::pauseForFuzzer(BaseClonerStage* stage) { // nb: This log message is specifically checked for in // initial_sync_test_fixture_test.js, so if you change it here you will need to change // it there. - log() << "Collection Cloner scheduled a remote command on the " - << describeForFuzzer(stage); - log() << "initialSyncFuzzerSynchronizationPoint1 fail point enabled."; + LOGV2(21066, + "Collection Cloner scheduled a remote command on the {describeForFuzzer_stage}", + "describeForFuzzer_stage"_attr = describeForFuzzer(stage)); + LOGV2(21067, "initialSyncFuzzerSynchronizationPoint1 fail point enabled."); initialSyncFuzzerSynchronizationPoint1.pauseWhileSet(); if (MONGO_unlikely(initialSyncFuzzerSynchronizationPoint2.shouldFail())) { - log() << "initialSyncFuzzerSynchronizationPoint2 fail point enabled."; + LOGV2(21068, "initialSyncFuzzerSynchronizationPoint2 fail point enabled."); initialSyncFuzzerSynchronizationPoint2.pauseWhileSet(); } } @@ -130,15 +134,21 @@ void BaseCloner::pauseForFuzzer(BaseClonerStage* stage) { } BaseCloner::AfterStageBehavior BaseCloner::runStage(BaseClonerStage* stage) { - LOG(1) << "Cloner " << getClonerName() << " running stage " << stage->getName(); + LOGV2_DEBUG(21069, + 1, + "Cloner {getClonerName} running stage {stage_getName}", + "getClonerName"_attr = getClonerName(), + "stage_getName"_attr = stage->getName()); pauseForFuzzer(stage); auto isThisStageFailPoint = [this, stage](const BSONObj& data) { return data["stage"].str() == stage->getName() && isMyFailPoint(data); }; hangBeforeClonerStage.executeIf( [&](const BSONObj& data) { - log() << "Cloner " << getClonerName() << " hanging before running stage " - << stage->getName(); + LOGV2(21070, + "Cloner {getClonerName} hanging before running stage {stage_getName}", + "getClonerName"_attr = getClonerName(), + "stage_getName"_attr = stage->getName()); while (!mustExit() && hangBeforeClonerStage.shouldFail(isThisStageFailPoint)) { sleepmillis(100); } @@ -147,14 +157,20 @@ BaseCloner::AfterStageBehavior BaseCloner::runStage(BaseClonerStage* stage) { auto afterStageBehavior = runStageWithRetries(stage); hangAfterClonerStage.executeIf( [&](const BSONObj& data) { - log() << "Cloner " << getClonerName() << " hanging after running stage " - << stage->getName(); + LOGV2(21071, + "Cloner {getClonerName} hanging after running stage {stage_getName}", + "getClonerName"_attr = getClonerName(), + "stage_getName"_attr = stage->getName()); while (!mustExit() && hangAfterClonerStage.shouldFail(isThisStageFailPoint)) { sleepmillis(100); } }, isThisStageFailPoint); - LOG(1) << "Cloner " << getClonerName() << " finished running stage " << stage->getName(); + LOGV2_DEBUG(21072, + 1, + "Cloner {getClonerName} finished running stage {stage_getName}", + "getClonerName"_attr = getClonerName(), + "stage_getName"_attr = stage->getName()); return afterStageBehavior; } @@ -170,7 +186,7 @@ Status BaseCloner::checkRollBackIdIsUnchanged() { if (ErrorCodes::isRetriableError(e)) { auto status = e.toStatus().withContext( ": failed while attempting to retrieve rollBackId after re-connect"); - LOG(1) << status; + LOGV2_DEBUG(21073, 1, "{status}", "status"_attr = status); return status; } throw; @@ -200,16 +216,23 @@ BaseCloner::AfterStageBehavior BaseCloner::runStageWithRetries(BaseClonerStage* // If lastError is set, this is a retry. hangBeforeRetryingClonerStage.executeIf( [&](const BSONObj& data) { - log() << "Cloner " << getClonerName() << " hanging before retrying stage " - << stage->getName(); + LOGV2( + 21074, + "Cloner {getClonerName} hanging before retrying stage {stage_getName}", + "getClonerName"_attr = getClonerName(), + "stage_getName"_attr = stage->getName()); while (!mustExit() && hangBeforeRetryingClonerStage.shouldFail(isThisStageFailPoint)) { sleepmillis(100); } }, isThisStageFailPoint); - log() << "Initial Sync retrying " << getClonerName() << " stage " - << stage->getName() << " due to " << lastError; + LOGV2(21075, + "Initial Sync retrying {getClonerName} stage {stage_getName} due to " + "{lastError}", + "getClonerName"_attr = getClonerName(), + "stage_getName"_attr = stage->getName(), + "lastError"_attr = lastError); bool shouldRetry = [&] { stdx::lock_guard<InitialSyncSharedData> lk(*_sharedData); return _sharedData->shouldRetryOperation(lk, &_retryableOp); @@ -225,9 +248,11 @@ BaseCloner::AfterStageBehavior BaseCloner::runStageWithRetries(BaseClonerStage* } hangBeforeCheckingRollBackIdClonerStage.executeIf( [&](const BSONObj& data) { - log() << "Cloner " << getClonerName() - << " hanging before checking rollBackId for stage " - << stage->getName(); + LOGV2(21076, + "Cloner {getClonerName} hanging before checking rollBackId for stage " + "{stage_getName}", + "getClonerName"_attr = getClonerName(), + "stage_getName"_attr = stage->getName()); while (!mustExit() && hangBeforeCheckingRollBackIdClonerStage.shouldFail( isThisStageFailPoint)) { @@ -248,12 +273,21 @@ BaseCloner::AfterStageBehavior BaseCloner::runStageWithRetries(BaseClonerStage* } catch (DBException& e) { lastError = e.toStatus(); if (!stage->isTransientError(lastError)) { - log() << "Non-retryable error occured during cloner " << getClonerName() - << " stage " + stage->getName() << ": " << lastError; + LOGV2(21077, + "Non-retryable error occured during cloner " + "{getClonerName}{stage_stage_getName}: {lastError}", + "getClonerName"_attr = getClonerName(), + "stage_stage_getName"_attr = " stage " + stage->getName(), + "lastError"_attr = lastError); throw; } - LOG(1) << "Transient error occured during cloner " << getClonerName() - << " stage " + stage->getName() << ": " << lastError; + LOGV2_DEBUG(21078, + 1, + "Transient error occured during cloner " + "{getClonerName}{stage_stage_getName}: {lastError}", + "getClonerName"_attr = getClonerName(), + "stage_stage_getName"_attr = " stage " + stage->getName(), + "lastError"_attr = lastError); } } } |