summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency/locker.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/concurrency/locker.h')
-rw-r--r--src/mongo/db/concurrency/locker.h33
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