summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/wiredtiger
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2023-03-14 16:12:23 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-14 18:39:04 +0000
commit36f85005ea321d5c8715ea0aac0bbfa9f509a26d (patch)
tree43cdb54057e1371e36b59881e8516060c6381d2a /src/mongo/db/storage/wiredtiger
parentab7bce4c05d5f4234022b441cc36aaed777e4fa1 (diff)
downloadmongo-36f85005ea321d5c8715ea0aac0bbfa9f509a26d.tar.gz
SERVER-74710 Reduce race with storage engine shutdown and RandomCursor destructor
Diffstat (limited to 'src/mongo/db/storage/wiredtiger')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index 66e28d92e70..adb97c8dae5 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -294,6 +294,15 @@ public:
// On destruction, we must always handle freeing the underlying raw WT_CURSOR pointer.
_saveStorageCursorOnDetachFromOperationContext = false;
+ // Shutdown does not wait for any threads running queries to be interrupted and exit.
+ // In addition, the RandomCursor destructor doesn't hold any global lock so we need to
+ // check if the server is shutting down to avoid calling into the storage engine, whose
+ // connection may have already been closed.
+ Status interruptStatus = _opCtx->checkForInterruptNoAssert();
+ if (interruptStatus.code() == ErrorCodes::InterruptedAtShutdown) {
+ return;
+ }
+
detachFromOperationContext();
}
}