summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency/d_concurrency.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/concurrency/d_concurrency.cpp')
-rw-r--r--src/mongo/db/concurrency/d_concurrency.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp
index db11862b65b..d63ac182dc1 100644
--- a/src/mongo/db/concurrency/d_concurrency.cpp
+++ b/src/mongo/db/concurrency/d_concurrency.cpp
@@ -133,6 +133,7 @@ Lock::GlobalLock::GlobalLock(OperationContext* opCtx,
: _opCtx(opCtx),
_result(LOCK_INVALID),
_pbwm(opCtx->lockState(), resourceIdParallelBatchWriterMode),
+ _fcvLock(opCtx->lockState(), resourceIdFeatureCompatibilityVersion),
_interruptBehavior(behavior),
_skipRSTLLock(skipRSTLLock),
_isOutermostLock(!opCtx->lockState()->isLocked()) {
@@ -148,6 +149,17 @@ Lock::GlobalLock::GlobalLock(OperationContext* opCtx,
}
});
+ if (_opCtx->lockState()->shouldConflictWithSetFeatureCompatibilityVersion() &&
+ !isSharedLockMode(lockMode)) {
+ _fcvLock.lock(_opCtx, MODE_IX, deadline);
+ }
+ ScopeGuard unlockFCVLock([this, lockMode] {
+ if (_opCtx->lockState()->shouldConflictWithSetFeatureCompatibilityVersion() &&
+ !isSharedLockMode(lockMode)) {
+ _fcvLock.unlock();
+ }
+ });
+
_result = LOCK_INVALID;
if (skipRSTLLock) {
_takeGlobalLockOnly(lockMode, deadline);
@@ -156,6 +168,7 @@ Lock::GlobalLock::GlobalLock(OperationContext* opCtx,
}
_result = LOCK_OK;
+ unlockFCVLock.dismiss();
unlockPBWM.dismiss();
} catch (const ExceptionForCat<ErrorCategory::Interruption>&) {
// The kLeaveUnlocked behavior suppresses this exception.
@@ -184,6 +197,7 @@ Lock::GlobalLock::GlobalLock(GlobalLock&& otherLock)
: _opCtx(otherLock._opCtx),
_result(otherLock._result),
_pbwm(std::move(otherLock._pbwm)),
+ _fcvLock(std::move(otherLock._fcvLock)),
_interruptBehavior(otherLock._interruptBehavior),
_skipRSTLLock(otherLock._skipRSTLLock),
_isOutermostLock(otherLock._isOutermostLock) {