summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Diener <matt.diener@mongodb.com>2022-10-03 16:05:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-03 17:37:40 +0000
commitedd8bd445afa1779fa453b1605f02b94afe6fde3 (patch)
tree65f1c466b0600381b61c16dfca8d414e0865a980
parent29156d5721db30c199deed16f15efbefb88b7af3 (diff)
downloadmongo-edd8bd445afa1779fa453b1605f02b94afe6fde3.tar.gz
SERVER-70010 Fix opCtx interruption checks in execution codebase
-rw-r--r--src/mongo/db/catalog/collection_validation.cpp2
-rw-r--r--src/mongo/db/commands/create_indexes_cmd.cpp2
-rw-r--r--src/mongo/db/concurrency/d_concurrency.cpp4
-rw-r--r--src/mongo/db/index/index_access_method.cpp2
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp5
-rw-r--r--src/mongo/db/storage/oplog_cap_maintainer_thread.cpp5
-rw-r--r--src/mongo/db/ttl.cpp2
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp2
8 files changed, 10 insertions, 14 deletions
diff --git a/src/mongo/db/catalog/collection_validation.cpp b/src/mongo/db/catalog/collection_validation.cpp
index 7b39f823443..a587b935bdb 100644
--- a/src/mongo/db/catalog/collection_validation.cpp
+++ b/src/mongo/db/catalog/collection_validation.cpp
@@ -626,7 +626,7 @@ Status validate(OperationContext* opCtx,
logAttrs(validateState.nss()),
logAttrs(validateState.uuid()));
} catch (const DBException& e) {
- if (opCtx->isKillPending() || e.code() == ErrorCodes::Interrupted) {
+ if (!opCtx->checkForInterruptNoAssert().isOK() || e.code() == ErrorCodes::Interrupted) {
LOGV2_OPTIONS(5160301,
{LogComponent::kIndex},
"Validation interrupted",
diff --git a/src/mongo/db/commands/create_indexes_cmd.cpp b/src/mongo/db/commands/create_indexes_cmd.cpp
index f6da49a5444..9d867dd340d 100644
--- a/src/mongo/db/commands/create_indexes_cmd.cpp
+++ b/src/mongo/db/commands/create_indexes_cmd.cpp
@@ -606,7 +606,7 @@ CreateIndexesReply runCreateIndexesWithCoordinator(OperationContext* opCtx,
throw;
} catch (const DBException& ex) {
- if (!opCtx->isKillPending()) {
+ if (opCtx->checkForInterruptNoAssert().isOK()) {
throw;
}
diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp
index f46c09d636e..6908803bf1c 100644
--- a/src/mongo/db/concurrency/d_concurrency.cpp
+++ b/src/mongo/db/concurrency/d_concurrency.cpp
@@ -165,10 +165,10 @@ Lock::GlobalLock::GlobalLock(OperationContext* opCtx,
unlockFCVLock.dismiss();
unlockPBWM.dismiss();
} catch (const DBException& ex) {
- // If our opCtx was killed or we got a LockTimeout or MaxTimeMSExpired, either throw or
+ // If our opCtx is interrupted or we got a LockTimeout or MaxTimeMSExpired, either throw or
// suppress the exception depending on the specified interrupt behavior. For any other
// exception, always throw.
- if ((!opCtx->isKillPending() && ex.code() != ErrorCodes::LockTimeout &&
+ if ((opCtx->checkForInterruptNoAssert().isOK() && ex.code() != ErrorCodes::LockTimeout &&
ex.code() != ErrorCodes::MaxTimeMSExpired) ||
_interruptBehavior == InterruptBehavior::kThrow) {
throw;
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index 7e7bc6a7c89..a3ef4649369 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -1075,7 +1075,7 @@ void SortedDataIndexAccessMethod::getKeys(OperationContext* opCtx,
multikeyPaths->clear();
}
- if (opCtx->isKillPending()) {
+ if (!opCtx->checkForInterruptNoAssert().isOK()) {
throw;
}
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 440cea078b1..6e17ed3789d 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -2407,9 +2407,8 @@ void IndexBuildsCoordinator::_runIndexBuildInner(
// * Explicitly abort the index build with abortIndexBuildByBuildUUID() before performing an
// operation that causes the index build to throw an error.
// TODO (SERVER-69264): Remove ErrorCodes::CannotCreateIndex.
- // TODO (SERVER-69496): Remove ErrorCodes::InterruptedAtShutdown.
- if (!opCtx->isKillPending() && status.code() != ErrorCodes::CannotCreateIndex &&
- status.code() != ErrorCodes::InterruptedAtShutdown) {
+ if (opCtx->checkForInterruptNoAssert().isOK() &&
+ status.code() != ErrorCodes::CannotCreateIndex) {
if (TestingProctor::instance().isEnabled()) {
LOGV2_FATAL(
6967700, "Unexpected error code during index build cleanup", "error"_attr = status);
diff --git a/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp b/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp
index 05b2776c6c8..c04ab030e33 100644
--- a/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp
+++ b/src/mongo/db/storage/oplog_cap_maintainer_thread.cpp
@@ -87,11 +87,8 @@ bool OplogCapMaintainerThread::_deleteExcessDocuments() {
"Caught an InterruptedDueToStorageChange exception, "
"but this thread can safely continue",
"error"_attr = e.toStatus());
- } catch (const ExceptionFor<ErrorCodes::InterruptedAtShutdown>&) {
- // TODO (SERVER-69496): Remove the ErrorCodes::InterruptedAtShutdown catch block.
- return false;
} catch (const DBException& ex) {
- if (opCtx->isKillPending()) {
+ if (!opCtx->checkForInterruptNoAssert().isOK()) {
return false;
}
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index aaa25f02cc0..6e4409015d2 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -495,7 +495,7 @@ bool TTLMonitor::_doTTLIndexDelete(OperationContext* opCtx,
"error"_attr = ex);
return false;
} catch (const DBException& ex) {
- if (opCtx->isKillPending()) {
+ if (!opCtx->checkForInterruptNoAssert().isOK()) {
// The exception is relevant to the entire TTL monitoring process, not just the specific
// TTL index. Let the exception escape so it can be addressed at the higher monitoring
// layer.
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index 393a3f75853..fc9b1f82f7e 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -102,7 +102,7 @@ protected:
wunit.commit();
abortOnExit.dismiss();
} catch (const DBException&) {
- if (_opCtx->isKillPending())
+ if (!_opCtx->checkForInterruptNoAssert().isOK())
return true;
throw;