From 5d0eaf8291050689b970581083abc5d0e6c931d1 Mon Sep 17 00:00:00 2001 From: Dianna Hohensee Date: Wed, 10 Feb 2021 17:39:04 -0500 Subject: SERVER-54116 AutoGetCollection*MaybeLockFree should pivot to locked if a storage snapshot is already open without the lock-free read operation flag set. This avoids using a -LockFree helper, via the DBDirectClient, that must reset the storage snapshot. --- src/mongo/db/db_raii.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp index c11e9ce664a..db8d0c205e9 100644 --- a/src/mongo/db/db_raii.cpp +++ b/src/mongo/db/db_raii.cpp @@ -60,8 +60,11 @@ bool supportsLockFreeRead(OperationContext* opCtx) { // Lock-free reads are not supported in multi-document transactions. // Lock-free reads are not supported under an exclusive lock (nested reads under exclusive lock // holding operations). + // Lock-free reads are not supported if a storage txn is already open w/o the lock-free reads + // operation flag set. return !storageGlobalParams.disableLockFreeReads && !opCtx->inMultiDocumentTransaction() && - !opCtx->lockState()->isWriteLocked(); + !opCtx->lockState()->isWriteLocked() && + !(opCtx->recoveryUnit()->isActive() && !opCtx->isLockFreeReadsOp()); } /** -- cgit v1.2.1