summaryrefslogtreecommitdiff
path: root/src/mongo/db/operation_context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/operation_context.cpp')
-rw-r--r--src/mongo/db/operation_context.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/operation_context.cpp b/src/mongo/db/operation_context.cpp
index 8817793d618..b8cd5935669 100644
--- a/src/mongo/db/operation_context.cpp
+++ b/src/mongo/db/operation_context.cpp
@@ -225,6 +225,14 @@ bool opShouldFail(Client* client, const BSONObj& failPointInfo) {
} // namespace
Status OperationContext::checkForInterruptNoAssert() noexcept {
+ const auto killStatus = getKillStatus();
+
+ if (_ignoreInterruptsExceptForReplStateChange &&
+ killStatus != ErrorCodes::InterruptedDueToReplStateChange &&
+ !_killRequestedForReplStateChange.loadRelaxed()) {
+ return Status::OK();
+ }
+
// TODO: Remove the MONGO_likely(hasClientAndServiceContext) once all operation contexts are
// constructed with clients.
const auto hasClientAndServiceContext = getClient() && getServiceContext();
@@ -257,7 +265,6 @@ Status OperationContext::checkForInterruptNoAssert() noexcept {
},
[&](auto&& data) { return opShouldFail(getClient(), data); });
- const auto killStatus = getKillStatus();
if (killStatus != ErrorCodes::OK) {
if (killStatus == ErrorCodes::TransactionExceededLifetimeLimitSeconds)
return Status(
@@ -356,6 +363,13 @@ void OperationContext::markKilled(ErrorCodes::Error killCode) {
LOGV2(20883, "Interrupted operation as its client disconnected", "opId"_attr = getOpID());
}
+ // Record that a kill was requested on this operationContext due to replication state change
+ // since it is possible to call markKilled() multiple times but only the first killCode will
+ // be preserved.
+ if (killCode == ErrorCodes::InterruptedDueToReplStateChange) {
+ _killRequestedForReplStateChange.store(true);
+ }
+
if (auto status = ErrorCodes::OK; _killCode.compareAndSwap(&status, killCode)) {
_baton->notify();
}