diff options
author | Maria van Keulen <maria@mongodb.com> | 2018-02-25 18:57:19 -0500 |
---|---|---|
committer | Maria van Keulen <maria@mongodb.com> | 2018-03-09 15:04:28 -0500 |
commit | a4d29b292f1bc42ae8133b0a0984c2b012c43528 (patch) | |
tree | a48307b9502bac095c30179b67f4db6cac155225 /src/mongo/db/server_options.h | |
parent | dec9b8f5f4b60b8f29244ecdfd759b6141aa7d34 (diff) | |
download | mongo-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.h | 15 |
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; } |