From 33fc66e686b4a48dc9527930c948f137d7628c14 Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Thu, 11 Jul 2019 11:13:40 -0400 Subject: SERVER-42154 abort index builds on NotMaster errors when using IndexBuildsCoordinator --- src/mongo/db/commands/create_indexes.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') 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& 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; -- cgit v1.2.1