diff options
Diffstat (limited to 'src/mongo/db/commands/create_indexes.cpp')
-rw-r--r-- | src/mongo/db/commands/create_indexes.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 0a9e6c50e56..25a58800dbc 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -584,6 +584,7 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx, "firstIndex"_attr = specs[0][IndexDescriptor::kIndexNameFieldName]); hangCreateIndexesBeforeStartingIndexBuild.pauseWhileSet(opCtx); + bool shouldContinueInBackground = false; try { auto buildIndexFuture = uassertStatusOK(indexBuildsCoord->startIndexBuild( opCtx, dbname, *collectionUUID, specs, buildUUID, protocol, indexBuildOptions)); @@ -610,9 +611,7 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx, // background and will complete when this node receives a commitIndexBuild oplog // entry from the new primary. if (ErrorCodes::InterruptedDueToReplStateChange == interruptionEx.code()) { - LOGV2(20442, - "Index build: ignoring interrupt and continuing in background", - "buildUUID"_attr = buildUUID); + shouldContinueInBackground = true; throw; } } @@ -648,9 +647,7 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx, // background and will complete when this node receives a commitIndexBuild oplog // entry from the new primary. if (IndexBuildProtocol::kTwoPhase == protocol) { - LOGV2(20445, - "Index build: ignoring interrupt and continuing in background", - "buildUUID"_attr = buildUUID); + shouldContinueInBackground = true; throw; } @@ -679,8 +676,15 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx, return true; } + if (shouldContinueInBackground) { + LOGV2(4760400, + "Index build: ignoring interrupt and continuing in background", + "buildUUID"_attr = buildUUID); + } else { + LOGV2(20449, "Index build: failed", "buildUUID"_attr = buildUUID, "error"_attr = ex); + } + // All other errors should be forwarded to the caller with index build information included. - LOGV2(20449, "Index build: failed", "buildUUID"_attr = buildUUID, "error"_attr = ex); ex.addContext(str::stream() << "Index build failed: " << buildUUID << ": Collection " << ns << " ( " << *collectionUUID << " )"); |