summaryrefslogtreecommitdiff
path: root/src/mongo/db/server_options.h
diff options
context:
space:
mode:
authorMaria van Keulen <maria@mongodb.com>2018-02-25 18:57:19 -0500
committerMaria van Keulen <maria@mongodb.com>2018-03-09 15:04:28 -0500
commita4d29b292f1bc42ae8133b0a0984c2b012c43528 (patch)
treea48307b9502bac095c30179b67f4db6cac155225 /src/mongo/db/server_options.h
parentdec9b8f5f4b60b8f29244ecdfd759b6141aa7d34 (diff)
downloadmongo-a4d29b292f1bc42ae8133b0a0984c2b012c43528.tar.gz
SERVER-32630 Ensure the fCV parameter is initialized before reading
Diffstat (limited to 'src/mongo/db/server_options.h')
-rw-r--r--src/mongo/db/server_options.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h
index 7c146b7b063..5e4e934e2b0 100644
--- a/src/mongo/db/server_options.h
+++ b/src/mongo/db/server_options.h
@@ -199,10 +199,21 @@ struct ServerGlobalParams {
}
/**
- * This safe getter for the featureCompatibilityVersion returns a default value when the
- * version has not yet been set.
+ * This safe getter for the featureCompatibilityVersion parameter ensures the parameter has
+ * been initialized with a meaningful value.
*/
const Version getVersion() const {
+ invariant(isVersionInitialized());
+ return _version.load();
+ }
+
+ /**
+ * This unsafe getter for the featureCompatibilityVersion parameter returns the last-stable
+ * featureCompatibilityVersion value if the parameter has not yet been initialized with a
+ * meaningful value. This getter should only be used if the parameter is intentionally read
+ * prior to the creation/parsing of the featureCompatibilityVersion document.
+ */
+ const Version getVersionUnsafe() const {
Version v = _version.load();
return (v == Version::kUnsetDefault36Behavior) ? Version::kFullyDowngradedTo36 : v;
}