summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-05-14 16:19:09 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-12 01:25:41 +0000
commit105e76edc52531274328fc051d6842a4c0c0686b (patch)
treeabe857d413e5b681237a2bfe74fe430f2bf9dab8 /src/mongo/db
parent6f7d770b36a493a724cde0a2d2a7efae62b30963 (diff)
downloadmongo-105e76edc52531274328fc051d6842a4c0c0686b.tar.gz
SERVER-48160 IndexBuildsCoordinator::_tryAbort() proceeds with abort if index build thread is not running
(cherry picked from commit 38d66e6ba3e01b3fb817c655decd077c9d9d7b0d)
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 7adc6ac77b8..6a0e4cec184 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -943,16 +943,18 @@ IndexBuildsCoordinator::TryAbortResult IndexBuildsCoordinator::_tryAbort(
IndexBuildState::kAborted, skipCheck, abortTimestamp, reason);
// Interrupt the builder thread so that it can no longer acquire locks or make progress.
+ // It is possible that the index build thread may have completed its operation and removed
+ // itself from the ServiceContext. This may happen in the case of an explicit db.killOp()
+ // operation or during shutdown.
+ // During normal operation, the abort logic, initiated through external means such as
+ // dropIndexes or internally through an indexing error, should have set the state in
+ // ReplIndexBuildState so that this code would not be reachable as it is no longer necessary
+ // to interrupt the builder thread here.
auto serviceContext = opCtx->getServiceContext();
- auto target = serviceContext->getLockedClient(replState->opId);
- if (!target) {
- LOGV2_FATAL(4656001,
- "Index builder thread did not appear to be running while aborting",
- "buildUUID"_attr = replState->buildUUID,
- "opId"_attr = replState->opId);
+ if (auto target = serviceContext->getLockedClient(replState->opId)) {
+ auto targetOpCtx = target->getOperationContext();
+ serviceContext->killOperation(target, targetOpCtx, ErrorCodes::IndexBuildAborted);
}
- serviceContext->killOperation(
- target, target->getOperationContext(), ErrorCodes::IndexBuildAborted);
// Set the signal. Because we have already interrupted the index build, it will not observe
// this signal. We do this so that other observers do not also try to abort the index build.