summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/feature_compatibility_version.h
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2021-03-24 11:05:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-26 07:53:45 +0000
commit7b990588faa09671660de9301e523c532fdb73aa (patch)
treeee9ee96b9c7415a3cb484398e4b5e9f2b97be6a8 /src/mongo/db/commands/feature_compatibility_version.h
parente8b1ac66fc3832b4fd7c61fe0320991f474675a2 (diff)
downloadmongo-7b990588faa09671660de9301e523c532fdb73aa.tar.gz
SERVER-54918 Hide the `fcvLock` behind a proper FCV set/check interface
Diffstat (limited to 'src/mongo/db/commands/feature_compatibility_version.h')
-rw-r--r--src/mongo/db/commands/feature_compatibility_version.h35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h
index 8c4af173521..41563a7f42c 100644
--- a/src/mongo/db/commands/feature_compatibility_version.h
+++ b/src/mongo/db/commands/feature_compatibility_version.h
@@ -38,21 +38,9 @@
namespace mongo {
-class BSONObj;
-class OperationContext;
-
class FeatureCompatibilityVersion {
public:
/**
- * Should be taken in shared mode by any operations that should not run while
- * setFeatureCompatibilityVersion is running.
- *
- * setFCV takes this lock in exclusive mode so that it both does not run with the shared mode
- * operations and does not run with itself.
- */
- static Lock::ResourceMutex fcvLock;
-
- /**
* Reads the featureCompatibilityVersion (FCV) document in admin.system.version and initializes
* the FCV global state. Returns an error if the FCV document exists and is invalid. Does not
* return an error if it is missing. This should be checked after startup with
@@ -106,6 +94,13 @@ public:
* current featureCompatibilityVersion value.
*/
static void updateMinWireVersion();
+
+ /**
+ * Returns a scoped object, which holds the 'fcvLock' in exclusive mode for the given scope. It
+ * must only be used by the setFeatureCompatibilityVersion command in order to serialise with
+ * concurrent 'FixedFCVRegions'.
+ */
+ static Lock::ExclusiveLock enterFCVChangeRegion(OperationContext* opCtx);
};
/**
@@ -113,19 +108,17 @@ public:
*/
class FixedFCVRegion {
public:
- explicit FixedFCVRegion(OperationContext* opCtx) {
- invariant(!opCtx->lockState()->isLocked());
- _lk.emplace(opCtx->lockState(), FeatureCompatibilityVersion::fcvLock);
- }
+ explicit FixedFCVRegion(OperationContext* opCtx);
+ ~FixedFCVRegion();
- ~FixedFCVRegion() = default;
+ bool operator==(const ServerGlobalParams::FeatureCompatibility::Version& other) const;
+ bool operator!=(const ServerGlobalParams::FeatureCompatibility::Version& other) const;
- void release() {
- _lk.reset();
- }
+ const ServerGlobalParams::FeatureCompatibility& operator*() const;
+ const ServerGlobalParams::FeatureCompatibility* operator->() const;
private:
- boost::optional<Lock::SharedLock> _lk;
+ Lock::SharedLock _lk;
};
} // namespace mongo