summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-07-11 11:13:40 -0400
committerBenety Goh <benety@mongodb.com>2019-07-11 11:14:14 -0400
commit33fc66e686b4a48dc9527930c948f137d7628c14 (patch)
tree26f8a0d89d33525a44b241346637d926ef769e4c /src
parentadab6702bc9869557c14eb8b0e888c6e854f4593 (diff)
downloadmongo-33fc66e686b4a48dc9527930c948f137d7628c14.tar.gz
SERVER-42154 abort index builds on NotMaster errors when using IndexBuildsCoordinator
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/create_indexes.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index ea679e2bca7..c34aebd5bc6 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -689,6 +689,18 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx,
log() << "Index build aborted: " << buildUUID << ": "
<< abortIndexFuture.getNoThrow(opCtx);
throw;
+ } catch (const ExceptionForCat<ErrorCategory::NotMasterError>& ex) {
+ log() << "Index build interrupted: " << buildUUID
+ << ": aborting index build due to change in replication state.";
+ auto abortIndexFuture = indexBuildsCoord->abortIndexBuildByBuildUUID(
+ buildUUID,
+ str::stream() << "Index build interrupted due to change in replication state: "
+ << buildUUID
+ << ": "
+ << ex.toString());
+ log() << "Index build aborted due to NotMaster error: " << buildUUID << ": "
+ << abortIndexFuture.getNoThrow(opCtx);
+ throw;
}
log() << "Index build completed: " << buildUUID;