diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2022-05-09 16:16:13 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-10 14:47:20 +0000 |
commit | 007846ad9c22495af276034c6d855572947e2742 (patch) | |
tree | 6c34832a63776c0f79c5e77cb624587b8a1516b0 /src/mongo/db/concurrency/locker.h | |
parent | bc1ac35debfc926c3d12f11f5ca7230010aacd55 (diff) | |
download | mongo-007846ad9c22495af276034c6d855572947e2742.tar.gz |
SERVER-65821 Allow prepared transactions to write commit decision across FCV barrierr5.3.2-rc0
(cherry picked from commit 5f15e515c617fca69a4a6dc4be741c19e2d07aa8)
Diffstat (limited to 'src/mongo/db/concurrency/locker.h')
-rw-r--r-- | src/mongo/db/concurrency/locker.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h index 37b6dbeedb8..5945ab1857b 100644 --- a/src/mongo/db/concurrency/locker.h +++ b/src/mongo/db/concurrency/locker.h @@ -494,6 +494,18 @@ public: } /** + * If set to false, this opts out of conflicting with the barrier created by the + * setFeatureCompatibilityVersion command. Code that opts-out must be ok with writes being able + * to start under one FCV and complete under a different FCV. + */ + void setShouldConflictWithSetFeatureCompatibilityVersion(bool newValue) { + _shouldConflictWithSetFeatureCompatibilityVersion = newValue; + } + bool shouldConflictWithSetFeatureCompatibilityVersion() const { + return _shouldConflictWithSetFeatureCompatibilityVersion; + } + + /** * If set to true, this opts out of a fatal assertion where operations which are holding open an * oplog hole cannot try to acquire subsequent locks. */ @@ -570,6 +582,7 @@ protected: private: bool _shouldConflictWithSecondaryBatchApplication = true; + bool _shouldConflictWithSetFeatureCompatibilityVersion = true; bool _shouldAllowLockAcquisitionOnTimestampedUnitOfWork = false; bool _shouldAcquireTicket = true; std::string _debugInfo; // Extra info about this locker for debugging purpose @@ -634,6 +647,26 @@ private: }; /** + * RAII-style class to opt out the FeatureCompatibilityVersion lock. + */ +class ShouldNotConflictWithSetFeatureCompatibilityVersionBlock { +public: + explicit ShouldNotConflictWithSetFeatureCompatibilityVersionBlock(Locker* lockState) + : _lockState(lockState), + _originalShouldConflict(_lockState->shouldConflictWithSetFeatureCompatibilityVersion()) { + _lockState->setShouldConflictWithSetFeatureCompatibilityVersion(false); + } + + ~ShouldNotConflictWithSetFeatureCompatibilityVersionBlock() { + _lockState->setShouldConflictWithSetFeatureCompatibilityVersion(_originalShouldConflict); + } + +private: + Locker* const _lockState; + const bool _originalShouldConflict; +}; + +/** * RAII-style class to opt out of a fatal assertion where operations that set a timestamp on a * WriteUnitOfWork cannot try to acquire subsequent locks. When an operation is writing at a * specific timestamp, it creates an oplog hole at that timestamp. The oplog visibility rules only |