From c2cffb0b0c2aeb5a1ec167b6bc9d68606dba2790 Mon Sep 17 00:00:00 2001 From: Eric Milkie Date: Tue, 8 May 2018 15:40:25 -0400 Subject: [PATCH] Finish the supportsDBLocking implementation. --- src/mongo/db/concurrency/lock_state.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 790ba748a0..110e29b9b2 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -357,7 +357,18 @@ LockResult LockerImpl::_lockGlobalBegin(OperationContext* opCtx, } _modeForTicket = mode; } - const LockResult result = lockBegin(opCtx, resourceIdGlobal, mode); + + LockMode actualLockMode = mode; + if (opCtx) { + if (!opCtx->getServiceContext()->getStorageEngine()->supportsDBLocking()) { + actualLockMode = isSharedLockMode(mode) ? MODE_S : MODE_X; + } + } else { + // Ensure only Global Exclusive lock requests can omit the operation context. + // This is needed at shutdown time, for example. + invariant(actualLockMode == MODE_X); + } + const LockResult result = lockBegin(opCtx, resourceIdGlobal, actualLockMode); if (result == LOCK_OK) return LOCK_OK; -- 2.14.3