summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@mongodb.com>2022-02-23 13:39:55 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-01 17:21:39 +0000
commit6b31c081a99aaf31402be98363b85647689070c9 (patch)
tree93acbd8ee93afc60986b827de5f1ef425dac7c96 /src/mongo/db
parent42c5d825b962b3190b8c8a639d022f6660eaeee0 (diff)
downloadmongo-6b31c081a99aaf31402be98363b85647689070c9.tar.gz
SERVER-63908 Allow stopping of index builds during initial sync
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index dfd59f9f620..9bd1677a4d6 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -1132,8 +1132,11 @@ bool IndexBuildsCoordinator::abortIndexBuildByBuildUUID(OperationContext* opCtx,
invariant(opCtx->lockState()->isRSTLLocked());
// Override the 'signalAction' as this is an initial syncing node.
+ // Don't override it if it's a rollback abort which would be explictly requested
+ // by the initial sync code.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- if (replCoord->getMemberState().startup2()) {
+ if (replCoord->getMemberState().startup2() &&
+ IndexBuildAction::kRollbackAbort != signalAction) {
LOGV2_DEBUG(4665902,
1,
"Overriding abort 'signalAction' for initial sync",
@@ -1276,7 +1279,10 @@ void IndexBuildsCoordinator::_completeAbort(OperationContext* opCtx,
}
case IndexBuildAction::kRollbackAbort: {
invariant(replState->protocol == IndexBuildProtocol::kTwoPhase);
- invariant(replCoord->getMemberState().rollback());
+ // File copy based initial sync does a rollback-like operation, so we allow STARTUP2
+ // to abort as well as rollback.
+ invariant(replCoord->getMemberState().rollback() ||
+ replCoord->getMemberState().startup2());
// Defer cleanup until builder thread is joined.
break;
}