summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishnu Kaushik <vishnu.kaushik@mongodb.com>2021-09-01 21:36:37 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-01 22:56:22 +0000
commit1a0f9486eb228065434d439fc417762c33aab4b7 (patch)
treedfbae9a0391a1a1f04dddade347e418edb1b030e
parent41bb7c7fb877f475f73265fe7c811e4e811ad174 (diff)
downloadmongo-1a0f9486eb228065434d439fc417762c33aab4b7.tar.gz
SERVER-58344 Remove ServerGlobalParams::FeatureCompatibility and replace references with generated FCV constants
-rw-r--r--buildscripts/idl/idl/cpp_types.py8
-rw-r--r--src/mongo/db/catalog/coll_mod.cpp6
-rw-r--r--src/mongo/db/catalog/collection.h11
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp6
-rw-r--r--src/mongo/db/catalog/collection_impl.h2
-rw-r--r--src/mongo/db/catalog/collection_mock.h2
-rw-r--r--src/mongo/db/catalog/database_impl.cpp6
-rw-r--r--src/mongo/db/commands/feature_compatibility_version.cpp89
-rw-r--r--src/mongo/db/commands/feature_compatibility_version.h10
-rw-r--r--src/mongo/db/commands/feature_compatibility_version_documentation.h4
-rw-r--r--src/mongo/db/commands/feature_compatibility_version_parser.cpp171
-rw-r--r--src/mongo/db/commands/feature_compatibility_version_parser.h73
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp2
-rw-r--r--src/mongo/db/commands/find_cmd.cpp2
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp50
-rw-r--r--src/mongo/db/exec/upsert_stage.cpp2
-rw-r--r--src/mongo/db/fcv_op_observer.cpp34
-rw-r--r--src/mongo/db/fcv_op_observer.h3
-rw-r--r--src/mongo/db/matcher/expression_parser.cpp2
-rw-r--r--src/mongo/db/namespace_string.cpp2
-rw-r--r--src/mongo/db/op_msg_fuzzer_fixture.cpp3
-rw-r--r--src/mongo/db/ops/insert.cpp2
-rw-r--r--src/mongo/db/pipeline/accumulation_statement.cpp10
-rw-r--r--src/mongo/db/pipeline/accumulation_statement.h4
-rw-r--r--src/mongo/db/pipeline/accumulator_multi.cpp32
-rw-r--r--src/mongo/db/pipeline/accumulator_sum.cpp5
-rw-r--r--src/mongo/db/pipeline/document_source.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source.h4
-rw-r--r--src/mongo/db/pipeline/document_source_densify.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_lookup.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_set_window_fields.cpp4
-rw-r--r--src/mongo/db/pipeline/expression.cpp14
-rw-r--r--src/mongo/db/pipeline/expression.h2
-rw-r--r--src/mongo/db/pipeline/expression_context.h3
-rw-r--r--src/mongo/db/pipeline/field_path.cpp2
-rw-r--r--src/mongo/db/pipeline/sharded_agg_helpers.cpp2
-rw-r--r--src/mongo/db/repl/initial_syncer.cpp5
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp26
-rw-r--r--src/mongo/db/repl/oplog.cpp2
-rw-r--r--src/mongo/db/repl/oplog_applier_impl_test.cpp2
-rw-r--r--src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp3
-rw-r--r--src/mongo/db/repl/tenant_migration_recipient_service.cpp2
-rw-r--r--src/mongo/db/repl/tenant_migration_recipient_service_test.cpp11
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp3
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp8
-rw-r--r--src/mongo/db/s/create_collection_coordinator.cpp2
-rw-r--r--src/mongo/db/s/sharding_ddl_util.cpp2
-rw-r--r--src/mongo/db/s/sharding_mongod_test_fixture.cpp3
-rw-r--r--src/mongo/db/server_options.h76
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp2
-rw-r--r--src/mongo/db/startup_recovery.cpp18
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp2
-rw-r--r--src/mongo/db/update/pipeline_executor.cpp2
-rw-r--r--src/mongo/db/update/storage_validation.cpp6
-rw-r--r--src/mongo/db/views/view_catalog.cpp6
-rw-r--r--src/mongo/dbtests/dbtests.cpp3
-rw-r--r--src/mongo/idl/basic_types.idl2
-rw-r--r--src/mongo/idl/feature_flag.cpp5
-rw-r--r--src/mongo/idl/feature_flag.h5
-rw-r--r--src/mongo/idl/feature_flag_test.cpp25
-rw-r--r--src/mongo/idl/idl_parser.h5
-rw-r--r--src/mongo/s/client/shard_registry.cpp2
-rw-r--r--src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp20
-rw-r--r--src/mongo/s/mongos_main.cpp3
-rw-r--r--src/mongo/shell/mongo_main.cpp2
-rw-r--r--src/mongo/unittest/ensure_fcv.h2
-rw-r--r--src/mongo/unittest/unittest.cpp4
67 files changed, 348 insertions, 497 deletions
diff --git a/buildscripts/idl/idl/cpp_types.py b/buildscripts/idl/idl/cpp_types.py
index 8971d5715c8..d8e37dfcc56 100644
--- a/buildscripts/idl/idl/cpp_types.py
+++ b/buildscripts/idl/idl/cpp_types.py
@@ -48,11 +48,11 @@ def is_primitive_scalar_type(cpp_type):
Primitive scalar types need to have a default value to prevent warnings from Coverity.
"""
cpp_type = cpp_type.replace(' ', '')
- # TODO (SERVER-50101): Remove 'FeatureCompatibility::Version' once IDL supports a commmand
- # cpp_type of C++ enum.
+ # TODO (SERVER-50101): Remove 'multiversion::FeatureCompatibilityVersion' once IDL supports
+ # a commmand cpp_type of C++ enum.
return cpp_type in [
- 'bool', 'double', 'ServerGlobalParams::FeatureCompatibility::Version', 'std::int32_t',
- 'std::uint32_t', 'std::uint64_t', 'std::int64_t'
+ 'bool', 'double', 'std::int32_t', 'std::uint32_t', 'std::uint64_t', 'std::int64_t',
+ 'multiversion::FeatureCompatibilityVersion'
]
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp
index 2e0f8bb4fad..605c4af8f7c 100644
--- a/src/mongo/db/catalog/coll_mod.cpp
+++ b/src/mongo/db/catalog/coll_mod.cpp
@@ -264,13 +264,13 @@ StatusWith<CollModRequest> parseCollModRequest(OperationContext* opCtx,
// If the feature compatibility version is not kLatest, and we are validating features
// as primary, ban the use of new agg features introduced in kLatest to prevent them
// from being persisted in the catalog.
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
+ boost::optional<multiversion::FeatureCompatibilityVersion>
maxFeatureCompatibilityVersion;
// (Generic FCV reference): This FCV check should exist across LTS binary versions.
- ServerGlobalParams::FeatureCompatibility::Version fcv;
+ multiversion::FeatureCompatibilityVersion fcv;
if (serverGlobalParams.validateFeaturesAsPrimary.load() &&
serverGlobalParams.featureCompatibility.isLessThan(
- ServerGlobalParams::FeatureCompatibility::kLatest, &fcv)) {
+ multiversion::GenericFCV::kLatest, &fcv)) {
maxFeatureCompatibilityVersion = fcv;
}
cmr.collValidator = coll->parseValidator(opCtx,
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index 46f44a022d5..511fa9d1e3c 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -485,12 +485,11 @@ public:
/**
* Returns a non-ok Status if validator is not legal for this collection.
*/
- virtual Validator parseValidator(
- OperationContext* opCtx,
- const BSONObj& validator,
- MatchExpressionParser::AllowedFeatureSet allowedFeatures,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
- maxFeatureCompatibilityVersion) const = 0;
+ virtual Validator parseValidator(OperationContext* opCtx,
+ const BSONObj& validator,
+ MatchExpressionParser::AllowedFeatureSet allowedFeatures,
+ boost::optional<multiversion::FeatureCompatibilityVersion>
+ maxFeatureCompatibilityVersion) const = 0;
/**
* Sets the validator for this collection.
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index ba8addcc4bb..86253b55ba5 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -566,8 +566,8 @@ Collection::Validator CollectionImpl::parseValidator(
OperationContext* opCtx,
const BSONObj& validator,
MatchExpressionParser::AllowedFeatureSet allowedFeatures,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
- maxFeatureCompatibilityVersion) const {
+ boost::optional<multiversion::FeatureCompatibilityVersion> maxFeatureCompatibilityVersion)
+ const {
if (MONGO_unlikely(allowSettingMalformedCollectionValidators.shouldFail())) {
return {validator, nullptr, nullptr};
}
@@ -894,7 +894,7 @@ void CollectionImpl::_cappedDeleteAsNeeded(OperationContext* opCtx,
}
bool useOldCappedDeleteBehaviour = serverGlobalParams.featureCompatibility.isLessThan(
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
if (!useOldCappedDeleteBehaviour && !opCtx->isEnforcingConstraints()) {
// With new capped delete behavior, secondaries only delete from capped collections via
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index da391eea8f0..0e926262417 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -280,7 +280,7 @@ public:
Validator parseValidator(OperationContext* opCtx,
const BSONObj& validator,
MatchExpressionParser::AllowedFeatureSet allowedFeatures,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
+ boost::optional<multiversion::FeatureCompatibilityVersion>
maxFeatureCompatibilityVersion = boost::none) const final;
/**
diff --git a/src/mongo/db/catalog/collection_mock.h b/src/mongo/db/catalog/collection_mock.h
index 0d609ff7c91..7cb2b2b302a 100644
--- a/src/mongo/db/catalog/collection_mock.h
+++ b/src/mongo/db/catalog/collection_mock.h
@@ -199,7 +199,7 @@ public:
Validator parseValidator(OperationContext* opCtx,
const BSONObj& validator,
MatchExpressionParser::AllowedFeatureSet allowedFeatures,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
+ boost::optional<multiversion::FeatureCompatibilityVersion>
maxFeatureCompatibilityVersion) const {
std::abort();
}
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index b8eef449892..965bc459cd2 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -926,10 +926,10 @@ Status DatabaseImpl::userCreateNS(OperationContext* opCtx,
// primary, ban the use of new agg features introduced in kLatest to prevent them from being
// persisted in the catalog.
// (Generic FCV reference): This FCV check should exist across LTS binary versions.
- ServerGlobalParams::FeatureCompatibility::Version fcv;
+ multiversion::FeatureCompatibilityVersion fcv;
if (serverGlobalParams.validateFeaturesAsPrimary.load() &&
- serverGlobalParams.featureCompatibility.isLessThan(
- ServerGlobalParams::FeatureCompatibility::kLatest, &fcv)) {
+ serverGlobalParams.featureCompatibility.isLessThan(multiversion::GenericFCV::kLatest,
+ &fcv)) {
expCtx->maxFeatureCompatibilityVersion = fcv;
}
diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp
index 0e91e7630b9..fa295377bec 100644
--- a/src/mongo/db/commands/feature_compatibility_version.cpp
+++ b/src/mongo/db/commands/feature_compatibility_version.cpp
@@ -56,13 +56,13 @@
#include "mongo/logv2/log.h"
#include "mongo/rpc/get_status_from_command_result.h"
#include "mongo/transport/service_entry_point.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
using repl::UnreplicatedWritesBlock;
-using FCVP = FeatureCompatibilityVersionParser;
-using FCVParams = ServerGlobalParams::FeatureCompatibility;
-using FCV = FCVParams::Version;
+using GenericFCV = multiversion::GenericFCV;
+using FCV = multiversion::FeatureCompatibilityVersion;
using namespace fmt::literals;
@@ -91,17 +91,17 @@ public:
// Steady states - they have FCV documents but no _transitions entries.
for (auto fcv :
- std::vector{FCVParams::kLastLTS, FCVParams::kLastContinuous, FCVParams::kLatest}) {
+ std::vector{GenericFCV::kLastLTS, GenericFCV::kLastContinuous, GenericFCV::kLatest}) {
_fcvDocuments[fcv] = makeFCVDoc(fcv);
}
for (auto [from, upgrading, to] :
- std::vector{std::make_tuple(FCVParams::kLastLTS,
- FCVParams::kUpgradingFromLastLTSToLatest,
- FCVParams::kLatest),
- std::make_tuple(FCVParams::kLastContinuous,
- FCVParams::kUpgradingFromLastContinuousToLatest,
- FCVParams::kLatest)}) {
+ std::vector{std::make_tuple(GenericFCV::kLastLTS,
+ GenericFCV::kUpgradingFromLastLTSToLatest,
+ GenericFCV::kLatest),
+ std::make_tuple(GenericFCV::kLastContinuous,
+ GenericFCV::kUpgradingFromLastContinuousToLatest,
+ GenericFCV::kLatest)}) {
for (auto isFromConfigServer : std::vector{false, true}) {
// Start or complete upgrading to latest. If this release's lastContinuous ==
// lastLTS then the second loop iteration just overwrites the first.
@@ -111,36 +111,36 @@ public:
_fcvDocuments[upgrading] = makeFCVDoc(from /* effective */, to /* target */);
}
- if (FCVParams::kLastLTS != FCVParams::kLastContinuous) {
+ if (GenericFCV::kLastLTS != GenericFCV::kLastContinuous) {
// Only config servers may request an upgrade from lastLTS to lastContinuous.
- _transitions[{FCVParams::kLastLTS, FCVParams::kLastContinuous, true}] =
- FCVParams::kUpgradingFromLastLTSToLastContinuous;
- _transitions[{FCVParams::kUpgradingFromLastLTSToLastContinuous,
- FCVParams::kLastContinuous,
- true}] = FCVParams::kLastContinuous;
- _fcvDocuments[FCVParams::kUpgradingFromLastLTSToLastContinuous] = makeFCVDoc(
- FCVParams::kLastLTS /* effective */, FCVParams::kLastContinuous /* target */);
+ _transitions[{GenericFCV::kLastLTS, GenericFCV::kLastContinuous, true}] =
+ GenericFCV::kUpgradingFromLastLTSToLastContinuous;
+ _transitions[{GenericFCV::kUpgradingFromLastLTSToLastContinuous,
+ GenericFCV::kLastContinuous,
+ true}] = GenericFCV::kLastContinuous;
+ _fcvDocuments[GenericFCV::kUpgradingFromLastLTSToLastContinuous] = makeFCVDoc(
+ GenericFCV::kLastLTS /* effective */, GenericFCV::kLastContinuous /* target */);
}
for (auto [downgrading, to] :
- std::vector{std::make_tuple(FCVParams::kDowngradingFromLatestToLastContinuous,
- FCVParams::kLastContinuous),
- std::make_tuple(FCVParams::kDowngradingFromLatestToLastLTS,
- FCVParams::kLastLTS)}) {
+ std::vector{std::make_tuple(GenericFCV::kDowngradingFromLatestToLastContinuous,
+ GenericFCV::kLastContinuous),
+ std::make_tuple(GenericFCV::kDowngradingFromLatestToLastLTS,
+ GenericFCV::kLastLTS)}) {
for (auto isFromConfigServer : std::vector{false, true}) {
// Start or complete downgrade from latest. If this release's lastContinuous ==
// lastLTS then the second loop iteration just overwrites the first.
- _transitions[{FCVParams::kLatest, to, isFromConfigServer}] = downgrading;
+ _transitions[{GenericFCV::kLatest, to, isFromConfigServer}] = downgrading;
_transitions[{downgrading, to, isFromConfigServer}] = to;
}
_fcvDocuments[downgrading] =
- makeFCVDoc(to /* effective */, to /* target */, FCVParams::kLatest /* previous */
+ makeFCVDoc(to /* effective */, to /* target */, GenericFCV::kLatest /* previous */
);
}
}
/**
- * True if a server in ServerGlobalParams::FeatureCompatibility::Version "fromVersion" can
+ * True if a server in multiversion::FeatureCompatibilityVersion "fromVersion" can
* transition to "newVersion". Different rules apply if the request is from a config server.
*/
bool permitsTransition(FCV fromVersion, FCV newVersion, bool isFromConfigServer) const {
@@ -150,7 +150,7 @@ public:
/**
* Get a feature compatibility version enum value from a document representing the
- * ServerGlobalParams::FeatureCompatibility::Version, or uassert if the document is invalid.
+ * multiversion::FeatureCompatibilityVersion, or uassert if the document is invalid.
*/
FCV versionFromFCVDoc(const FeatureCompatibilityVersionDocument& fcvDoc) const {
auto it = std::find_if(_fcvDocuments.begin(), _fcvDocuments.end(), [&](const auto& value) {
@@ -219,7 +219,7 @@ void runUpdateCommand(OperationContext* opCtx, const FeatureCompatibilityVersion
BSONObjBuilder updateSpec(updates.subobjStart());
{
BSONObjBuilder queryFilter(updateSpec.subobjStart("q"));
- queryFilter.append("_id", FeatureCompatibilityVersionParser::kParameterName);
+ queryFilter.append("_id", multiversion::kParameterName);
}
{
BSONObjBuilder updateMods(updateSpec.subobjStart("u"));
@@ -249,7 +249,7 @@ boost::optional<BSONObj> FeatureCompatibilityVersion::findFeatureCompatibilityVe
AutoGetCollection autoColl(opCtx, NamespaceString::kServerConfigurationNamespace, MODE_IX);
invariant(autoColl.ensureDbExists(), NamespaceString::kServerConfigurationNamespace.ns());
- const auto query = BSON("_id" << FeatureCompatibilityVersionParser::kParameterName);
+ const auto query = BSON("_id" << multiversion::kParameterName);
const auto swFcv = repl::StorageInterface::get(opCtx)->findById(
opCtx, NamespaceString::kServerConfigurationNamespace, query["_id"]);
if (!swFcv.isOK()) {
@@ -267,7 +267,7 @@ void FeatureCompatibilityVersion::validateSetFeatureCompatibilityVersionRequest(
uassert(
5147403,
"cannot set featureCompatibilityVersion to '{}' while featureCompatibilityVersion is '{}'"_format(
- FCVP::toString(newVersion), FCVP::toString(fromVersion)),
+ multiversion::toString(newVersion), multiversion::toString(fromVersion)),
fcvTransitions.permitsTransition(fromVersion, newVersion, isFromConfigServer));
auto setFCVPhase = setFCVRequest.getPhase();
@@ -316,8 +316,8 @@ void FeatureCompatibilityVersion::validateSetFeatureCompatibilityVersionRequest(
void FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument(
OperationContext* opCtx,
- ServerGlobalParams::FeatureCompatibility::Version fromVersion,
- ServerGlobalParams::FeatureCompatibility::Version newVersion,
+ FCV fromVersion,
+ FCV newVersion,
bool isFromConfigServer,
boost::optional<Timestamp> changeTimestamp,
bool setTargetVersion) {
@@ -336,9 +336,7 @@ void FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument(
// The timestamp must be removed when downgrading to version 4.9 or 4.4. This is necessary to
// avoid the presence of an unknown field that old binaries are unable to deserialize.
- if (transitioningVersion == ServerGlobalParams::FeatureCompatibility::Version::kVersion49 ||
- transitioningVersion ==
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44) {
+ if (transitioningVersion == FCV::kVersion_4_9 || transitioningVersion == FCV::kVersion_4_4) {
fcvDoc.setChangeTimestamp(boost::none);
} else {
fcvDoc.setChangeTimestamp(changeTimestamp);
@@ -370,9 +368,9 @@ void FeatureCompatibilityVersion::setIfCleanStartup(OperationContext* opCtx,
FeatureCompatibilityVersionDocument fcvDoc;
if (storeUpgradeVersion) {
- fcvDoc.setVersion(FCVParams::kLatest);
+ fcvDoc.setVersion(GenericFCV::kLatest);
} else {
- fcvDoc.setVersion(FCVParams::kLastLTS);
+ fcvDoc.setVersion(GenericFCV::kLastLTS);
}
// We then insert the featureCompatibilityVersion document into the server configuration
@@ -400,23 +398,23 @@ bool FeatureCompatibilityVersion::isCleanStartUp() {
void FeatureCompatibilityVersion::updateMinWireVersion() {
WireSpec& wireSpec = WireSpec::instance();
const auto currentFcv = serverGlobalParams.featureCompatibility.getVersion();
- if (currentFcv == FCVParams::kLatest ||
+ if (currentFcv == GenericFCV::kLatest ||
(serverGlobalParams.featureCompatibility.isUpgradingOrDowngrading() &&
- currentFcv != FCVParams::kUpgradingFromLastLTSToLastContinuous)) {
+ currentFcv != GenericFCV::kUpgradingFromLastLTSToLastContinuous)) {
// FCV == kLatest or FCV is upgrading/downgrading to or from kLatest.
WireSpec::Specification newSpec = *wireSpec.get();
newSpec.incomingInternalClient.minWireVersion = LATEST_WIRE_VERSION;
newSpec.outgoing.minWireVersion = LATEST_WIRE_VERSION;
wireSpec.reset(std::move(newSpec));
- } else if (currentFcv == FCVParams::kUpgradingFromLastLTSToLastContinuous ||
- currentFcv == FCVParams::kLastContinuous) {
+ } else if (currentFcv == GenericFCV::kUpgradingFromLastLTSToLastContinuous ||
+ currentFcv == GenericFCV::kLastContinuous) {
// FCV == kLastContinuous or upgrading to kLastContinuous.
WireSpec::Specification newSpec = *wireSpec.get();
newSpec.incomingInternalClient.minWireVersion = LAST_CONT_WIRE_VERSION;
newSpec.outgoing.minWireVersion = LAST_CONT_WIRE_VERSION;
wireSpec.reset(std::move(newSpec));
} else {
- invariant(currentFcv == FCVParams::kLastLTS);
+ invariant(currentFcv == GenericFCV::kLastLTS);
WireSpec::Specification newSpec = *wireSpec.get();
newSpec.incomingInternalClient.minWireVersion = LAST_LTS_WIRE_VERSION;
newSpec.outgoing.minWireVersion = LAST_LTS_WIRE_VERSION;
@@ -461,8 +459,7 @@ void FeatureCompatibilityVersion::initializeForStartup(OperationContext* opCtx)
{logv2::LogTag::kStartupWarnings},
"A featureCompatibilityVersion upgrade/downgrade did not complete. To fix this, use "
"the setFeatureCompatibilityVersion command to resume the upgrade/downgrade",
- "currentfeatureCompatibilityVersion"_attr =
- FeatureCompatibilityVersionParser::toString(version));
+ "currentfeatureCompatibilityVersion"_attr = multiversion::toString(version));
}
}
@@ -594,13 +591,11 @@ const ServerGlobalParams::FeatureCompatibility* FixedFCVRegion::operator->() con
return &serverGlobalParams.featureCompatibility;
}
-bool FixedFCVRegion::operator==(
- const ServerGlobalParams::FeatureCompatibility::Version& other) const {
+bool FixedFCVRegion::operator==(const FCV& other) const {
return serverGlobalParams.featureCompatibility.getVersion() == other;
}
-bool FixedFCVRegion::operator!=(
- const ServerGlobalParams::FeatureCompatibility::Version& other) const {
+bool FixedFCVRegion::operator!=(const FCV& other) const {
return !(*this == other);
}
diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h
index 93c4065fde6..a0250b1f4f3 100644
--- a/src/mongo/db/commands/feature_compatibility_version.h
+++ b/src/mongo/db/commands/feature_compatibility_version.h
@@ -69,7 +69,7 @@ public:
static void validateSetFeatureCompatibilityVersionRequest(
OperationContext* opCtx,
const SetFeatureCompatibilityVersion& setFCVRequest,
- ServerGlobalParams::FeatureCompatibility::Version fromVersion);
+ multiversion::FeatureCompatibilityVersion fromVersion);
/**
* Updates the on-disk feature compatibility version document for the transition fromVersion ->
@@ -77,8 +77,8 @@ public:
*/
static void updateFeatureCompatibilityVersionDocument(
OperationContext* opCtx,
- ServerGlobalParams::FeatureCompatibility::Version fromVersion,
- ServerGlobalParams::FeatureCompatibility::Version newVersion,
+ multiversion::FeatureCompatibilityVersion fromVersion,
+ multiversion::FeatureCompatibilityVersion newVersion,
bool isFromConfigServer,
boost::optional<Timestamp> timestamp,
bool setTargetVersion);
@@ -132,8 +132,8 @@ public:
explicit FixedFCVRegion(OperationContext* opCtx);
~FixedFCVRegion();
- bool operator==(const ServerGlobalParams::FeatureCompatibility::Version& other) const;
- bool operator!=(const ServerGlobalParams::FeatureCompatibility::Version& other) const;
+ bool operator==(const multiversion::FeatureCompatibilityVersion& other) const;
+ bool operator!=(const multiversion::FeatureCompatibilityVersion& other) const;
const ServerGlobalParams::FeatureCompatibility& operator*() const;
const ServerGlobalParams::FeatureCompatibility* operator->() const;
diff --git a/src/mongo/db/commands/feature_compatibility_version_documentation.h b/src/mongo/db/commands/feature_compatibility_version_documentation.h
index 2926667d9ab..cfdfe8f1025 100644
--- a/src/mongo/db/commands/feature_compatibility_version_documentation.h
+++ b/src/mongo/db/commands/feature_compatibility_version_documentation.h
@@ -39,9 +39,9 @@ using namespace fmt::literals;
const std::string kCompatibilityLink =
"https://docs.mongodb.com/master/release-notes/{}-compatibility/#feature-compatibility"_format(
- FeatureCompatibilityVersionParser::kLastLTS);
+ multiversion::toString(multiversion::GenericFCV::kLastLTS));
const std::string kUpgradeLink =
"https://docs.mongodb.com/master/release-notes/{}/#upgrade-procedures"_format(
- FeatureCompatibilityVersionParser::kLastLTS);
+ multiversion::toString(multiversion::GenericFCV::kLastLTS));
} // namespace feature_compatibility_version_documentation
} // namespace mongo
diff --git a/src/mongo/db/commands/feature_compatibility_version_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_parser.cpp
index 087755d9186..063d129ca95 100644
--- a/src/mongo/db/commands/feature_compatibility_version_parser.cpp
+++ b/src/mongo/db/commands/feature_compatibility_version_parser.cpp
@@ -36,123 +36,76 @@
#include "mongo/db/commands/feature_compatibility_version_document_gen.h"
#include "mongo/db/commands/feature_compatibility_version_documentation.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
-using FeatureCompatibilityParams = ServerGlobalParams::FeatureCompatibility;
+using GenericFCV = multiversion::GenericFCV;
-constexpr StringData FeatureCompatibilityVersionParser::kParameterName;
-
-constexpr StringData FeatureCompatibilityVersionParser::kLastLTS;
-constexpr StringData FeatureCompatibilityVersionParser::kLastContinuous;
-constexpr StringData FeatureCompatibilityVersionParser::kLatest;
-
-FeatureCompatibilityParams::Version FeatureCompatibilityVersionParser::parseVersion(
+multiversion::FeatureCompatibilityVersion FeatureCompatibilityVersionParser::parseVersion(
StringData versionString) {
- if (versionString == kLastLTS) {
- return FeatureCompatibilityParams::kLastLTS;
- }
- if (versionString == kLastContinuous) {
- return FeatureCompatibilityParams::kLastContinuous;
+ if (versionString == multiversion::toString(GenericFCV::kLastLTS)) {
+ return GenericFCV::kLastLTS;
}
- if (versionString == kLatest) {
- return FeatureCompatibilityParams::kLatest;
+ if (versionString == multiversion::toString(GenericFCV::kLastContinuous)) {
+ return GenericFCV::kLastContinuous;
}
- uasserted(4926900,
- str::stream() << "Invalid value for " << kParameterName << "document in "
- << NamespaceString::kServerConfigurationNamespace.toString()
- << ", found " << versionString << ", expected '" << kLastLTS << "' or '"
- << kLastContinuous << "' or '" << kLatest << ". See "
- << feature_compatibility_version_documentation::kCompatibilityLink
- << ".");
-}
-
-FeatureCompatibilityParams::Version FeatureCompatibilityVersionParser::parseVersionForFeatureFlags(
- StringData versionString) {
- if (versionString == kVersion51) {
- return FeatureCompatibilityParams::Version::kVersion51;
- }
-
- if (versionString == kVersion50) {
- return FeatureCompatibilityParams::Version::kFullyDowngradedTo50;
+ if (versionString == multiversion::toString(GenericFCV::kLatest)) {
+ return GenericFCV::kLatest;
}
- if (versionString == kVersion49) {
- return FeatureCompatibilityParams::Version::kVersion49;
- }
-
- if (versionString == kVersion48) {
- return FeatureCompatibilityParams::Version::kVersion48;
- }
-
- if (versionString == kVersion47) {
- return FeatureCompatibilityParams::Version::kVersion47;
- }
-
- if (versionString == kVersion44) {
- return FeatureCompatibilityParams::Version::kFullyDowngradedTo44;
- }
+ uasserted(
+ 4926900,
+ str::stream() << "Invalid value for " << multiversion::kParameterName << "document in "
+ << NamespaceString::kServerConfigurationNamespace.toString() << ", found "
+ << versionString << ", expected '"
+ << multiversion::toString(GenericFCV::kLastLTS) << "' or '"
+ << multiversion::toString(GenericFCV::kLastContinuous) << "' or '"
+ << multiversion::toString(GenericFCV::kLatest) << ". See "
+ << feature_compatibility_version_documentation::kCompatibilityLink << ".");
+}
- uasserted(5715400,
- str::stream() << "Invalid FCV version " << versionString << " for feature flag");
+multiversion::FeatureCompatibilityVersion
+FeatureCompatibilityVersionParser::parseVersionForFeatureFlags(StringData versionString) {
+ return multiversion::parseVersionForFeatureFlags(versionString);
}
StringData FeatureCompatibilityVersionParser::serializeVersion(
- FeatureCompatibilityParams::Version version) {
- if (version == FeatureCompatibilityParams::kLastLTS) {
- return kLastLTS;
- }
- if (version == FeatureCompatibilityParams::kLastContinuous) {
- return kLastContinuous;
- }
- if (version == FeatureCompatibilityParams::kLatest) {
- return kLatest;
- }
- // It is a bug if we hit here.
- invariant(false, "Invalid version value for featureCompatibilityVersion documents");
- MONGO_UNREACHABLE
+ multiversion::FeatureCompatibilityVersion version) {
+ invariant(version == GenericFCV::kLastLTS || version == GenericFCV::kLastContinuous ||
+ version == GenericFCV::kLatest,
+ "Invalid version value for featureCompatibilityVersion documents");
+
+ return multiversion::toString(version);
}
StringData FeatureCompatibilityVersionParser::serializeVersionForFeatureFlags(
- FeatureCompatibilityParams::Version version) {
- if (version == FeatureCompatibilityParams::Version::kVersion51) {
- return kVersion51;
- }
-
- if (version == FeatureCompatibilityParams::Version::kFullyDowngradedTo50) {
- return kVersion50;
- }
-
- if (version == FeatureCompatibilityParams::Version::kVersion49) {
- return kVersion49;
- }
-
- if (version == FeatureCompatibilityParams::Version::kVersion48) {
- return kVersion48;
- }
-
- if (version == FeatureCompatibilityParams::Version::kVersion47) {
- return kVersion47;
- }
-
- if (version == FeatureCompatibilityParams::Version::kFullyDowngradedTo44) {
- return kVersion44;
- }
- // It is a bug if we hit here.
- invariant(false, "Invalid version value for feature flag");
- MONGO_UNREACHABLE
+ multiversion::FeatureCompatibilityVersion version) {
+ switch (version) {
+ case multiversion::FeatureCompatibilityVersion::kVersion_4_4:
+ case multiversion::FeatureCompatibilityVersion::kVersion_4_7:
+ case multiversion::FeatureCompatibilityVersion::kVersion_4_8:
+ case multiversion::FeatureCompatibilityVersion::kVersion_4_9:
+ case multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0:
+ case multiversion::FeatureCompatibilityVersion::kVersion_5_1:
+ return multiversion::toString(version);
+ default:
+ invariant(false, "Invalid version value for feature flag.");
+ }
+
+ MONGO_UNREACHABLE;
}
Status FeatureCompatibilityVersionParser::validatePreviousVersionField(
- FeatureCompatibilityParams::Version version) {
- if (version == FeatureCompatibilityParams::kLatest) {
+ multiversion::FeatureCompatibilityVersion version) {
+ if (version == GenericFCV::kLatest) {
return Status::OK();
}
return Status(ErrorCodes::Error(4926901),
"when present, 'previousVersion' field must be the latest binary version");
}
-StatusWith<FeatureCompatibilityParams::Version> FeatureCompatibilityVersionParser::parse(
+StatusWith<multiversion::FeatureCompatibilityVersion> FeatureCompatibilityVersionParser::parse(
const BSONObj& featureCompatibilityVersionDoc) {
try {
auto fcvDoc = FeatureCompatibilityVersionDocument::parse(
@@ -163,8 +116,7 @@ StatusWith<FeatureCompatibilityParams::Version> FeatureCompatibilityVersionParse
auto previousVersion = fcvDoc.getPreviousVersion();
// Downgrading FCV.
- if ((version == FeatureCompatibilityParams::kLastLTS ||
- version == FeatureCompatibilityParams::kLastContinuous) &&
+ if ((version == GenericFCV::kLastLTS || version == GenericFCV::kLastContinuous) &&
version == targetVersion) {
// Downgrading FCV must have a "previousVersion" field.
if (!previousVersion) {
@@ -172,18 +124,18 @@ StatusWith<FeatureCompatibilityParams::Version> FeatureCompatibilityVersionParse
str::stream()
<< "Missing field "
<< FeatureCompatibilityVersionDocument::kPreviousVersionFieldName
- << " in downgrading states for " << kParameterName
+ << " in downgrading states for " << multiversion::kParameterName
<< " document in "
<< NamespaceString::kServerConfigurationNamespace.toString()
<< ": " << featureCompatibilityVersionDoc << ". See "
<< feature_compatibility_version_documentation::kCompatibilityLink
<< ".");
}
- if (version == FeatureCompatibilityParams::kLastLTS) {
+ if (version == GenericFCV::kLastLTS) {
// Downgrading to last-lts.
- return FeatureCompatibilityParams::kDowngradingFromLatestToLastLTS;
+ return GenericFCV::kDowngradingFromLatestToLastLTS;
} else {
- return FeatureCompatibilityParams::kDowngradingFromLatestToLastContinuous;
+ return GenericFCV::kDowngradingFromLatestToLastContinuous;
}
}
@@ -193,7 +145,7 @@ StatusWith<FeatureCompatibilityParams::Version> FeatureCompatibilityVersionParse
str::stream()
<< "Unexpected field "
<< FeatureCompatibilityVersionDocument::kPreviousVersionFieldName
- << " in non-downgrading states for " << kParameterName
+ << " in non-downgrading states for " << multiversion::kParameterName
<< " document in "
<< NamespaceString::kServerConfigurationNamespace.toString() << ": "
<< featureCompatibilityVersionDoc << ". See "
@@ -205,31 +157,30 @@ StatusWith<FeatureCompatibilityParams::Version> FeatureCompatibilityVersionParse
if (targetVersion) {
// For upgrading FCV, "targetVersion" must be kLatest or kLastContinuous and "version"
// must be kLastContinuous or kLastLTS.
- if (targetVersion == FeatureCompatibilityParams::kLastLTS ||
- version == ServerGlobalParams::FeatureCompatibility::kLatest) {
+ if (targetVersion == GenericFCV::kLastLTS || version == GenericFCV::kLatest) {
return Status(ErrorCodes::Error(4926904),
str::stream()
- << "Invalid " << kParameterName << " document in "
+ << "Invalid " << multiversion::kParameterName << " document in "
<< NamespaceString::kServerConfigurationNamespace.toString()
<< ": " << featureCompatibilityVersionDoc << ". See "
<< feature_compatibility_version_documentation::kCompatibilityLink
<< ".");
}
- if (version == FeatureCompatibilityParams::kLastLTS) {
- return targetVersion == FeatureCompatibilityParams::kLastContinuous
- ? FeatureCompatibilityParams::kUpgradingFromLastLTSToLastContinuous
- : FeatureCompatibilityParams::kUpgradingFromLastLTSToLatest;
+ if (version == GenericFCV::kLastLTS) {
+ return targetVersion == GenericFCV::kLastContinuous
+ ? GenericFCV::kUpgradingFromLastLTSToLastContinuous
+ : GenericFCV::kUpgradingFromLastLTSToLatest;
} else {
uassert(5070601,
str::stream()
- << "Invalid " << kParameterName << " document in "
+ << "Invalid " << multiversion::kParameterName << " document in "
<< NamespaceString::kServerConfigurationNamespace.toString() << ": "
<< featureCompatibilityVersionDoc << ". See "
<< feature_compatibility_version_documentation::kCompatibilityLink
<< ".",
- version == ServerGlobalParams::FeatureCompatibility::kLastContinuous);
- return FeatureCompatibilityParams::kUpgradingFromLastContinuousToLatest;
+ version == GenericFCV::kLastContinuous);
+ return GenericFCV::kUpgradingFromLastContinuousToLatest;
}
}
@@ -238,7 +189,7 @@ StatusWith<FeatureCompatibilityParams::Version> FeatureCompatibilityVersionParse
} catch (const DBException& e) {
auto status = e.toStatus();
status.addContext(str::stream()
- << "Invalid " << kParameterName << " document in "
+ << "Invalid " << multiversion::kParameterName << " document in "
<< NamespaceString::kServerConfigurationNamespace.toString() << ": "
<< featureCompatibilityVersionDoc << ". See "
<< feature_compatibility_version_documentation::kCompatibilityLink
diff --git a/src/mongo/db/commands/feature_compatibility_version_parser.h b/src/mongo/db/commands/feature_compatibility_version_parser.h
index b20cb3a1b01..1fa8e88ab9b 100644
--- a/src/mongo/db/commands/feature_compatibility_version_parser.h
+++ b/src/mongo/db/commands/feature_compatibility_version_parser.h
@@ -29,95 +29,40 @@
#pragma once
-#include "mongo/db/server_options.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
-using FeatureCompatibilityParams = ServerGlobalParams::FeatureCompatibility;
-
/**
* Helpers to parse featureCompatibilityVersion document BSON objects into
- * ServerGlobalParams::FeatureCompatibility::Version enums and convert
- * ServerGlobalParams::FeatureCompatibility::Version enums into strings.
+ * multiversion::FeatureCompatibilityVersion enums.
*/
class FeatureCompatibilityVersionParser {
public:
- static constexpr StringData kVersion44 = "4.4"_sd; // Remove once old feature flags are deleted
- static constexpr StringData kVersion47 = "4.7"_sd; // Remove once old feature flags are deleted
- static constexpr StringData kVersion48 = "4.8"_sd; // Remove once old feature flags are deleted
- static constexpr StringData kVersion49 = "4.9"_sd; // Remove once old feature flags are deleted
- static constexpr StringData kVersion50 = "5.0"_sd;
- static constexpr StringData kVersion51 = "5.1"_sd;
- static constexpr StringData kVersionDowngradingFrom51To50 = "downgrading from 5.1 to 5.0"_sd;
- static constexpr StringData kVersionUpgradingFrom50To51 = "upgrading from 5.0 to 5.1"_sd;
- static constexpr StringData kVersionUnset = "Unset"_sd;
-
- static constexpr StringData kParameterName = "featureCompatibilityVersion"_sd;
-
- static constexpr StringData kLastLTS = kVersion50;
- static constexpr StringData kLastContinuous = kVersion50;
- static constexpr StringData kLatest = kVersion51;
- static constexpr StringData kUpgradingFromLastLTSToLatest = kVersionUpgradingFrom50To51;
- static constexpr StringData kUpgradingFromLastContinuousToLatest = kVersionUpgradingFrom50To51;
- // kVersionUpgradingFromLastLTSToLastContinuous should assigned kVersionUnset when kLastLTS and
- // kLastContinuous are equal.
- static constexpr StringData kVersionUpgradingFromLastLTSToLastContinuous = kVersionUnset;
- static constexpr StringData kDowngradingFromLatestToLastLTS = kVersionDowngradingFrom51To50;
- static constexpr StringData kDowngradingFromLatestToLastContinuous =
- kVersionDowngradingFrom51To50;
-
// Used to verify that FCV values in 'admin.system.version' are valid and equal to one of
// { lastLTS, lastContinuous, latest }.
- static FeatureCompatibilityParams::Version parseVersion(StringData versionString);
+ static multiversion::FeatureCompatibilityVersion parseVersion(StringData versionString);
// Used to parse FCV values for feature flags. It is acceptable to have feature flag versions
// that are not one of { lastLTS, lastContinuous, latest } while the server code is
// transitioning to the next LTS release. This is to avoid having the upgrade of FCV constants
// be blocked on old code removal.
- static FeatureCompatibilityParams::Version parseVersionForFeatureFlags(
+ static multiversion::FeatureCompatibilityVersion parseVersionForFeatureFlags(
StringData versionString);
- static StringData serializeVersion(FeatureCompatibilityParams::Version version);
+ static StringData serializeVersion(multiversion::FeatureCompatibilityVersion version);
- static StringData serializeVersionForFeatureFlags(FeatureCompatibilityParams::Version version);
+ static StringData serializeVersionForFeatureFlags(
+ multiversion::FeatureCompatibilityVersion version);
- static Status validatePreviousVersionField(FeatureCompatibilityParams::Version version);
+ static Status validatePreviousVersionField(multiversion::FeatureCompatibilityVersion version);
/**
* Parses the featureCompatibilityVersion document from the server configuration collection
* (admin.system.version), and returns the state represented by the combination of the
* targetVersion and version.
*/
- static StatusWith<FeatureCompatibilityParams::Version> parse(
+ static StatusWith<multiversion::FeatureCompatibilityVersion> parse(
const BSONObj& featureCompatibilityVersionDoc);
-
- /**
- * Useful for message logging.
- */
- static StringData toString(FeatureCompatibilityParams::Version version) {
- if (version == FeatureCompatibilityParams::Version::kUnsetDefault50Behavior) {
- return kVersionUnset;
- } else if (version == FeatureCompatibilityParams::kLastLTS) {
- return kLastLTS;
- } else if (version == FeatureCompatibilityParams::kDowngradingFromLatestToLastLTS) {
- return kDowngradingFromLatestToLastLTS;
- } else if (version == FeatureCompatibilityParams::kUpgradingFromLastLTSToLastContinuous) {
- // kUpgradingFromLastLTSToLastContinuous is only a valid FCV state when last-continuous
- // and last-lts are not equal. Otherwise, it is set to kInvalid.
- invariant(version != FeatureCompatibilityParams::Version::kInvalid);
- return kVersionUpgradingFromLastLTSToLastContinuous;
- } else if (version == FeatureCompatibilityParams::kUpgradingFromLastLTSToLatest) {
- return kUpgradingFromLastLTSToLatest;
- } else if (version == FeatureCompatibilityParams::kLastContinuous) {
- return kLastContinuous;
- } else if (version == FeatureCompatibilityParams::kDowngradingFromLatestToLastContinuous) {
- return kDowngradingFromLatestToLastContinuous;
- } else if (version == FeatureCompatibilityParams::kUpgradingFromLastContinuousToLatest) {
- return kUpgradingFromLastContinuousToLatest;
- } else if (version == FeatureCompatibilityParams::kLatest) {
- return kLatest;
- }
- MONGO_UNREACHABLE;
- }
};
} // namespace mongo
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 9222576fbe7..e8f2e4f4357 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -488,7 +488,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict
if (updateResult.containsDotsAndDollarsField &&
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50)) {
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) {
// If it's an upsert, increment 'inserts' metric, otherwise increment 'updates'.
dotsAndDollarsFieldsCounters.incrementForUpsert(!updateResult.upsertedId.isEmpty());
}
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index f2df0422be9..a684f314bfe 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -82,7 +82,7 @@ std::unique_ptr<FindCommandRequest> translateNtoReturnToLimitOrBatchSize(
"the ntoreturn find command parameter is not supported when FCV >= 5.1",
!(fcvState.isVersionInitialized() &&
fcvState.isGreaterThanOrEqualTo(
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51) &&
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1) &&
findCmd->getNtoreturn()));
const auto ntoreturn = findCmd->getNtoreturn().get_value_or(0);
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index ba3fcbf1de1..3c952c922b7 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -75,14 +75,14 @@
#include "mongo/util/fail_point.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/str.h"
+#include "mongo/util/version/releases.h"
using namespace fmt::literals;
namespace mongo {
namespace {
-using FCVP = FeatureCompatibilityVersionParser;
-using FeatureCompatibility = ServerGlobalParams::FeatureCompatibility;
+using GenericFCV = multiversion::GenericFCV;
MONGO_FAIL_POINT_DEFINE(failUpgrading);
MONGO_FAIL_POINT_DEFINE(hangWhileUpgrading);
@@ -192,15 +192,18 @@ public:
std::string help() const override {
std::stringstream h;
h << "Set the featureCompatibilityVersion used by this cluster. If set to '"
- << FCVP::kLastLTS << "', then features introduced in versions greater than '"
- << FCVP::kLastLTS << "' will be disabled";
- if (FCVP::kLastContinuous != FCVP::kLastLTS) {
- h << " If set to '" << FCVP::kLastContinuous << "', then features introduced in '"
- << FCVP::kLatest << "' will be disabled.";
+ << multiversion::toString(GenericFCV::kLastLTS)
+ << "', then features introduced in versions greater than '"
+ << multiversion::toString(GenericFCV::kLastLTS) << "' will be disabled";
+ if (GenericFCV::kLastContinuous != GenericFCV::kLastLTS) {
+ h << " If set to '" << multiversion::toString(GenericFCV::kLastContinuous)
+ << "', then features introduced in '" << multiversion::toString(GenericFCV::kLatest)
+ << "' will be disabled.";
}
- h << " If set to '" << FCVP::kLatest << "', then '" << FCVP::kLatest
+ h << " If set to '" << multiversion::toString(GenericFCV::kLatest) << "', then '"
+ << multiversion::toString(GenericFCV::kLatest)
<< "' features are enabled, and all nodes in the cluster must be binary version "
- << FCVP::kLatest << ". See "
+ << multiversion::toString(GenericFCV::kLatest) << ". See "
<< feature_compatibility_version_documentation::kCompatibilityLink << ".";
return h.str();
}
@@ -254,15 +257,16 @@ public:
const auto requestedVersion = request.getCommandParameter();
const auto actualVersion = serverGlobalParams.featureCompatibility.getVersion();
if (request.getDowngradeOnDiskChanges()) {
- uassert(
- ErrorCodes::IllegalOperation,
- str::stream() << "Cannot set featureCompatibilityVersion to "
- << FCVP::serializeVersion(requestedVersion) << " with '"
- << SetFeatureCompatibilityVersion::kDowngradeOnDiskChangesFieldName
- << "' set to true. This is only allowed when downgrading to "
- << FCVP::kLastContinuous,
- requestedVersion <= actualVersion &&
- requestedVersion == FeatureCompatibility::kLastContinuous);
+ uassert(ErrorCodes::IllegalOperation,
+ str::stream()
+ << "Cannot set featureCompatibilityVersion to "
+ << FeatureCompatibilityVersionParser::serializeVersion(requestedVersion)
+ << " with '"
+ << SetFeatureCompatibilityVersion::kDowngradeOnDiskChangesFieldName
+ << "' set to true. This is only allowed when downgrading to "
+ << multiversion::toString(GenericFCV::kLastContinuous),
+ requestedVersion <= actualVersion &&
+ requestedVersion == GenericFCV::kLastContinuous);
}
if (requestedVersion == actualVersion) {
@@ -408,7 +412,7 @@ private:
// TODO: Remove once FCV 6.0 becomes last-lts
const auto requestedVersion = request.getCommandParameter();
- if (requestedVersion >= FeatureCompatibility::Version::kVersion51) {
+ if (requestedVersion >= multiversion::FeatureCompatibilityVersion::kVersion_5_1) {
ShardingCatalogManager::get(opCtx)->upgradeMetadataTo51Phase2(opCtx);
}
@@ -442,7 +446,7 @@ private:
// Secondary indexes on time-series measurements are only supported in 5.1 and up. If the
// user tries to downgrade the cluster to an earlier version, they must first remove all
// incompatible secondary indexes on time-series measurements.
- if (requestedVersion < FeatureCompatibility::Version::kVersion51) {
+ if (requestedVersion < multiversion::FeatureCompatibilityVersion::kVersion_5_1) {
for (const auto& dbName : DatabaseHolder::get(opCtx)->getNames()) {
Lock::DBLock dbLock(opCtx, dbName, MODE_IS);
catalog::forEachCollectionFromDb(
@@ -510,7 +514,7 @@ private:
opCtx, CommandHelpers::appendMajorityWriteConcern(requestPhase2.toBSON({}))));
// TODO: Remove once FCV 6.0 becomes last-lts
- if (requestedVersion < FeatureCompatibility::Version::kVersion51) {
+ if (requestedVersion < multiversion::FeatureCompatibilityVersion::kVersion_5_1) {
ShardingCatalogManager::get(opCtx)->downgradeMetadataToPre51Phase2(opCtx);
}
}
@@ -518,7 +522,7 @@ private:
hangWhileDowngrading.pauseWhileSet(opCtx);
if (request.getDowngradeOnDiskChanges()) {
- invariant(requestedVersion == FeatureCompatibility::kLastContinuous);
+ invariant(requestedVersion == GenericFCV::kLastContinuous);
_downgradeOnDiskChanges();
LOGV2(4875603, "Downgrade of on-disk format complete.");
}
@@ -531,7 +535,7 @@ private:
void _downgradeOnDiskChanges() {
LOGV2(4975602,
"Downgrading on-disk format to reflect the last-continuous version.",
- "last_continuous_version"_attr = FCVP::kLastContinuous);
+ "last_continuous_version"_attr = multiversion::toString(GenericFCV::kLastContinuous));
}
/**
diff --git a/src/mongo/db/exec/upsert_stage.cpp b/src/mongo/db/exec/upsert_stage.cpp
index 79aa21fdf31..035419f4c39 100644
--- a/src/mongo/db/exec/upsert_stage.cpp
+++ b/src/mongo/db/exec/upsert_stage.cpp
@@ -282,7 +282,7 @@ void UpsertStage::_assertDocumentToBeInsertedIsValid(const mb::Document& documen
bool allowTopLevelDollarPrefixes =
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
storage_validation::storageValid(document,
allowTopLevelDollarPrefixes,
true, /* Should validate for storage */
diff --git a/src/mongo/db/fcv_op_observer.cpp b/src/mongo/db/fcv_op_observer.cpp
index c2043daa86c..76f9c86692d 100644
--- a/src/mongo/db/fcv_op_observer.cpp
+++ b/src/mongo/db/fcv_op_observer.cpp
@@ -52,16 +52,14 @@ namespace mongo {
MONGO_FAIL_POINT_DEFINE(pauseBeforeCloseCxns);
MONGO_FAIL_POINT_DEFINE(finishedDropConnections);
-using FeatureCompatibilityParams = ServerGlobalParams::FeatureCompatibility;
-
void FcvOpObserver::_setVersion(OperationContext* opCtx,
- ServerGlobalParams::FeatureCompatibility::Version newVersion,
+ multiversion::FeatureCompatibilityVersion newVersion,
boost::optional<Timestamp> commitTs) {
// We set the last FCV update timestamp before setting the new FCV, to make sure we never
// read an FCV that is not stable. We might still read a stale one.
if (commitTs)
FeatureCompatibilityVersion::advanceLastFCVUpdateTimestamp(*commitTs);
- boost::optional<FeatureCompatibilityParams::Version> prevVersion;
+ boost::optional<multiversion::FeatureCompatibilityVersion> prevVersion;
if (serverGlobalParams.featureCompatibility.isVersionInitialized()) {
prevVersion = serverGlobalParams.featureCompatibility.getVersion();
@@ -71,7 +69,7 @@ void FcvOpObserver::_setVersion(OperationContext* opCtx,
// (Generic FCV reference): This FCV check should exist across LTS binary versions.
if (serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::kLatest) ||
+ multiversion::GenericFCV::kLatest) ||
serverGlobalParams.featureCompatibility.isUpgradingOrDowngrading()) {
// minWireVersion == maxWireVersion on kLatest FCV or upgrading/downgrading FCV.
// Close all incoming connections from internal clients with binary versions lower than
@@ -110,13 +108,12 @@ void FcvOpObserver::_setVersion(OperationContext* opCtx,
// 1. Setting featureCompatibilityVersion from downgrading to fullyDowngraded.
// 2. Setting featureCompatibilityVersion from fullyDowngraded to upgrading.
// (Generic FCV reference): This FCV check should exist across LTS binary versions.
- const auto shouldIncrementTopologyVersion =
- newVersion == FeatureCompatibilityParams::kLastLTS ||
+ const auto shouldIncrementTopologyVersion = newVersion == multiversion::GenericFCV::kLastLTS ||
(prevVersion &&
- prevVersion.get() == FeatureCompatibilityParams::kDowngradingFromLatestToLastContinuous) ||
- newVersion == FeatureCompatibilityParams::kUpgradingFromLastLTSToLatest ||
- newVersion == FeatureCompatibilityParams::kUpgradingFromLastContinuousToLatest ||
- newVersion == FeatureCompatibilityParams::kUpgradingFromLastLTSToLastContinuous;
+ prevVersion.get() == multiversion::GenericFCV::kDowngradingFromLatestToLastContinuous) ||
+ newVersion == multiversion::GenericFCV::kUpgradingFromLastLTSToLatest ||
+ newVersion == multiversion::GenericFCV::kUpgradingFromLastContinuousToLatest ||
+ newVersion == multiversion::GenericFCV::kUpgradingFromLastLTSToLastContinuous;
if (isReplSet && shouldIncrementTopologyVersion) {
replCoordinator->incrementTopologyVersion();
@@ -126,7 +123,7 @@ void FcvOpObserver::_setVersion(OperationContext* opCtx,
void FcvOpObserver::_onInsertOrUpdate(OperationContext* opCtx, const BSONObj& doc) {
auto idElement = doc["_id"];
if (idElement.type() != BSONType::String ||
- idElement.String() != FeatureCompatibilityVersionParser::kParameterName) {
+ idElement.String() != multiversion::kParameterName) {
return;
}
auto newVersion = uassertStatusOK(FeatureCompatibilityVersionParser::parse(doc));
@@ -137,12 +134,12 @@ void FcvOpObserver::_onInsertOrUpdate(OperationContext* opCtx, const BSONObj& do
bool isDifferent = true;
if (serverGlobalParams.featureCompatibility.isVersionInitialized()) {
const auto currentVersion = serverGlobalParams.featureCompatibility.getVersion();
- attrs.add("currentVersion", FeatureCompatibilityVersionParser::toString(currentVersion));
+ attrs.add("currentVersion", multiversion::toString(currentVersion));
isDifferent = currentVersion != newVersion;
}
if (isDifferent) {
- attrs.add("newVersion", FeatureCompatibilityVersionParser::toString(newVersion));
+ attrs.add("newVersion", multiversion::toString(newVersion));
LOGV2(20459, "Setting featureCompatibilityVersion", attrs);
}
@@ -183,8 +180,7 @@ void FcvOpObserver::onDelete(OperationContext* opCtx,
invariant(optDocKey, nss.ns());
if (nss.isServerConfigurationCollection()) {
auto id = optDocKey.get().getId().firstElement();
- if (id.type() == BSONType::String &&
- id.String() == FeatureCompatibilityVersionParser::kParameterName) {
+ if (id.type() == BSONType::String && id.String() == multiversion::kParameterName) {
uasserted(40670, "removing FeatureCompatibilityVersion document is not allowed");
}
}
@@ -193,7 +189,7 @@ void FcvOpObserver::onDelete(OperationContext* opCtx,
void FcvOpObserver::onReplicationRollback(OperationContext* opCtx,
const RollbackObserverInfo& rbInfo) {
// Ensures the in-memory and on-disk FCV states are consistent after a rollback.
- const auto query = BSON("_id" << FeatureCompatibilityVersionParser::kParameterName);
+ const auto query = BSON("_id" << multiversion::kParameterName);
const auto swFcv = repl::StorageInterface::get(opCtx)->findById(
opCtx, NamespaceString::kServerConfigurationNamespace, query["_id"]);
if (swFcv.isOK()) {
@@ -204,8 +200,8 @@ void FcvOpObserver::onReplicationRollback(OperationContext* opCtx,
auto diskFcv = swVersion.getValue();
LOGV2(4675801,
"Setting featureCompatibilityVersion as part of rollback",
- "newVersion"_attr = FeatureCompatibilityVersionParser::toString(diskFcv),
- "oldVersion"_attr = FeatureCompatibilityVersionParser::toString(memoryFcv));
+ "newVersion"_attr = multiversion::toString(diskFcv),
+ "oldVersion"_attr = multiversion::toString(memoryFcv));
_setVersion(opCtx, diskFcv);
// The rollback FCV is already in the stable snapshot.
FeatureCompatibilityVersion::clearLastFCVUpdateTimestamp();
diff --git a/src/mongo/db/fcv_op_observer.h b/src/mongo/db/fcv_op_observer.h
index f42172c4b07..7de88e944b8 100644
--- a/src/mongo/db/fcv_op_observer.h
+++ b/src/mongo/db/fcv_op_observer.h
@@ -31,6 +31,7 @@
#include "mongo/db/op_observer_noop.h"
#include "mongo/db/server_options.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
@@ -197,7 +198,7 @@ private:
* servers and closing open transactions if necessary. Increments the server TopologyVersion.
*/
static void _setVersion(OperationContext* opCtx,
- ServerGlobalParams::FeatureCompatibility::Version newVersion,
+ multiversion::FeatureCompatibilityVersion newVersion,
boost::optional<Timestamp> commitTs = boost::none);
/**
diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp
index 9ed73402765..cd2b1bb2e1a 100644
--- a/src/mongo/db/matcher/expression_parser.cpp
+++ b/src/mongo/db/matcher/expression_parser.cpp
@@ -299,7 +299,7 @@ StatusWithMatchExpression parse(const BSONObj& obj,
const auto dotsAndDollarsHint =
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50)
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)
? ". If you have a field name that starts with a '$' symbol, consider using "
"$getField or $setField."
: "";
diff --git a/src/mongo/db/namespace_string.cpp b/src/mongo/db/namespace_string.cpp
index 6e0868f31c4..0375f5f9900 100644
--- a/src/mongo/db/namespace_string.cpp
+++ b/src/mongo/db/namespace_string.cpp
@@ -172,7 +172,7 @@ bool NamespaceString::isLegalClientSystemNS(
if (coll() == kSystemDotViewsCollectionName)
return true;
if (currentFCV.isGreaterThanOrEqualTo(
- ServerGlobalParams::FeatureCompatibility::Version::kVersion47) &&
+ multiversion::FeatureCompatibilityVersion::kVersion_4_7) &&
// While this FCV check is being added in 4.9, the namespace was allowed in 4.7 binaries
// without an FCV check.
isTemporaryReshardingCollection()) {
diff --git a/src/mongo/db/op_msg_fuzzer_fixture.cpp b/src/mongo/db/op_msg_fuzzer_fixture.cpp
index a2f6d29eadc..4918aa2468d 100644
--- a/src/mongo/db/op_msg_fuzzer_fixture.cpp
+++ b/src/mongo/db/op_msg_fuzzer_fixture.cpp
@@ -102,8 +102,7 @@ OpMsgFuzzerFixture::OpMsgFuzzerFixture(bool skipGlobalInitializers)
storageGlobalParams.repair = false;
serverGlobalParams.enableMajorityReadConcern = false;
// (Generic FCV reference): Initialize FCV.
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLatest);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
initializeStorageEngine(opCtx.get(),
StorageEngineInitFlags::kAllowNoLockFile |
diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp
index e0accaac460..85edc50cfb4 100644
--- a/src/mongo/db/ops/insert.cpp
+++ b/src/mongo/db/ops/insert.cpp
@@ -112,7 +112,7 @@ StatusWith<BSONObj> fixDocumentForInsert(OperationContext* opCtx,
if (fieldName[0] == '$') {
if (!serverGlobalParams.featureCompatibility.isVersionInitialized() ||
!serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50)) {
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) {
return StatusWith<BSONObj>(ErrorCodes::BadValue,
str::stream()
<< "Document can't have $ prefixed field names: "
diff --git a/src/mongo/db/pipeline/accumulation_statement.cpp b/src/mongo/db/pipeline/accumulation_statement.cpp
index 3e83633e018..18cca9fd32a 100644
--- a/src/mongo/db/pipeline/accumulation_statement.cpp
+++ b/src/mongo/db/pipeline/accumulation_statement.cpp
@@ -47,16 +47,15 @@ using std::string;
namespace {
// Used to keep track of which Accumulators are registered under which name.
-using ParserRegistration =
- std::pair<AccumulationStatement::Parser,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version>>;
+using ParserRegistration = std::pair<AccumulationStatement::Parser,
+ boost::optional<multiversion::FeatureCompatibilityVersion>>;
static StringMap<ParserRegistration> parserMap;
} // namespace
void AccumulationStatement::registerAccumulator(
std::string name,
AccumulationStatement::Parser parser,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion) {
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion) {
auto it = parserMap.find(name);
massert(28722,
str::stream() << "Duplicate accumulator (" << name << ") registered.",
@@ -65,8 +64,7 @@ void AccumulationStatement::registerAccumulator(
}
AccumulationStatement::Parser& AccumulationStatement::getParser(
- StringData name,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> allowedMaxVersion) {
+ StringData name, boost::optional<multiversion::FeatureCompatibilityVersion> allowedMaxVersion) {
auto it = parserMap.find(name);
uassert(
15952, str::stream() << "unknown group operator '" << name << "'", it != parserMap.end());
diff --git a/src/mongo/db/pipeline/accumulation_statement.h b/src/mongo/db/pipeline/accumulation_statement.h
index 2d9ed8de52e..7144ada54fc 100644
--- a/src/mongo/db/pipeline/accumulation_statement.h
+++ b/src/mongo/db/pipeline/accumulation_statement.h
@@ -192,7 +192,7 @@ public:
static void registerAccumulator(
std::string name,
Parser parser,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion);
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion);
/**
* Retrieves the Parser for the accumulator specified by the given name, and raises an error if
@@ -201,7 +201,7 @@ public:
*/
static Parser& getParser(
StringData name,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> allowedMaxVersion);
+ boost::optional<multiversion::FeatureCompatibilityVersion> allowedMaxVersion);
// The field name is used to store the results of the accumulation in a result document.
std::string fieldName;
diff --git a/src/mongo/db/pipeline/accumulator_multi.cpp b/src/mongo/db/pipeline/accumulator_multi.cpp
index 8284f1a9a20..4c27b381df3 100644
--- a/src/mongo/db/pipeline/accumulator_multi.cpp
+++ b/src/mongo/db/pipeline/accumulator_multi.cpp
@@ -28,47 +28,45 @@
*/
#include "mongo/db/pipeline/accumulator_multi.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
using FirstLastSense = AccumulatorFirstLastN::Sense;
using MinMaxSense = AccumulatorMinMax::Sense;
-REGISTER_ACCUMULATOR_WITH_MIN_VERSION(
- maxN,
- AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMax>,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
-REGISTER_ACCUMULATOR_WITH_MIN_VERSION(
- minN,
- AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMin>,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+REGISTER_ACCUMULATOR_WITH_MIN_VERSION(maxN,
+ AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMax>,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
+REGISTER_ACCUMULATOR_WITH_MIN_VERSION(minN,
+ AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMin>,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
REGISTER_EXPRESSION_WITH_MIN_VERSION(maxN,
AccumulatorMinMaxN::parseExpression<MinMaxSense::kMax>,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
REGISTER_EXPRESSION_WITH_MIN_VERSION(minN,
AccumulatorMinMaxN::parseExpression<MinMaxSense::kMin>,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
REGISTER_ACCUMULATOR_WITH_MIN_VERSION(
firstN,
AccumulatorFirstLastN::parseFirstLastN<FirstLastSense::kFirst>,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
-REGISTER_ACCUMULATOR_WITH_MIN_VERSION(
- lastN,
- AccumulatorFirstLastN::parseFirstLastN<FirstLastSense::kLast>,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
+REGISTER_ACCUMULATOR_WITH_MIN_VERSION(lastN,
+ AccumulatorFirstLastN::parseFirstLastN<FirstLastSense::kLast>,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
REGISTER_EXPRESSION_WITH_MIN_VERSION(firstN,
AccumulatorFirstLastN::parseExpression<FirstLastSense::kFirst>,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
REGISTER_EXPRESSION_WITH_MIN_VERSION(lastN,
AccumulatorFirstLastN::parseExpression<FirstLastSense::kLast>,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
// TODO SERVER-57884 Add $firstN/$lastN as window functions.
AccumulatorN::AccumulatorN(ExpressionContext* const expCtx)
diff --git a/src/mongo/db/pipeline/accumulator_sum.cpp b/src/mongo/db/pipeline/accumulator_sum.cpp
index 8322048df55..fca549e28d0 100644
--- a/src/mongo/db/pipeline/accumulator_sum.cpp
+++ b/src/mongo/db/pipeline/accumulator_sum.cpp
@@ -49,8 +49,9 @@ using boost::intrusive_ptr;
REGISTER_ACCUMULATOR(sum, genericParseSingleExpressionAccumulator<AccumulatorSum>);
REGISTER_STABLE_EXPRESSION(sum, ExpressionFromAccumulator<AccumulatorSum>::parse);
REGISTER_REMOVABLE_WINDOW_FUNCTION(sum, AccumulatorSum, WindowFunctionSum);
-REGISTER_ACCUMULATOR_WITH_MIN_VERSION(
- count, parseCountAccumulator, ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+REGISTER_ACCUMULATOR_WITH_MIN_VERSION(count,
+ parseCountAccumulator,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1);
REGISTER_WINDOW_FUNCTION(count, window_function::parseCountWindowFunction);
diff --git a/src/mongo/db/pipeline/document_source.cpp b/src/mongo/db/pipeline/document_source.cpp
index 3a75c9606f1..b4cf3a59362 100644
--- a/src/mongo/db/pipeline/document_source.cpp
+++ b/src/mongo/db/pipeline/document_source.cpp
@@ -68,7 +68,7 @@ DocumentSource::DocumentSource(const StringData stageName,
namespace {
struct ParserRegistration {
Parser parser;
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion;
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion;
};
// Used to keep track of which DocumentSources are registered under which name.
static StringMap<ParserRegistration> parserMap;
@@ -77,7 +77,7 @@ static StringMap<ParserRegistration> parserMap;
void DocumentSource::registerParser(
string name,
Parser parser,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion) {
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion) {
auto it = parserMap.find(name);
massert(28707,
str::stream() << "Duplicate document source (" << name << ") registered.",
@@ -87,7 +87,7 @@ void DocumentSource::registerParser(
void DocumentSource::registerParser(
string name,
SimpleParser simpleParser,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion) {
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion) {
Parser parser =
[simpleParser = std::move(simpleParser)](
diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h
index bd4be19059e..9ab0990f880 100644
--- a/src/mongo/db/pipeline/document_source.h
+++ b/src/mongo/db/pipeline/document_source.h
@@ -409,7 +409,7 @@ public:
static void registerParser(
std::string name,
Parser parser,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion);
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion);
/**
* Convenience wrapper for the common case, when DocumentSource::Parser returns a list of one
* DocumentSource.
@@ -420,7 +420,7 @@ public:
static void registerParser(
std::string name,
SimpleParser simpleParser,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion);
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion);
/**
* Returns true if the DocumentSource has a query.
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp
index d48c3bbfbf5..2d6dc1aacd3 100644
--- a/src/mongo/db/pipeline/document_source_densify.cpp
+++ b/src/mongo/db/pipeline/document_source_densify.cpp
@@ -110,7 +110,7 @@ REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
document_source_densify::createFromBson,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1,
::mongo::feature_flags::gFeatureFlagDensify.isEnabledAndIgnoreFCV());
REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
@@ -119,7 +119,7 @@ REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
DocumentSourceInternalDensify::createFromBson,
AllowedWithApiStrict::kInternal,
AllowedWithClientType::kInternal,
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1,
::mongo::feature_flags::gFeatureFlagDensify.isEnabledAndIgnoreFCV());
namespace document_source_densify {
diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp
index c1850127909..4f42c0a7f32 100644
--- a/src/mongo/db/pipeline/document_source_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup.cpp
@@ -1022,7 +1022,7 @@ void DocumentSourceLookUp::serializeToArrayWithBothSyntaxes(
void DocumentSourceLookUp::serializeToArray(
std::vector<Value>& array, boost::optional<ExplainOptions::Verbosity> explain) const {
if (serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kVersion49)) {
+ multiversion::FeatureCompatibilityVersion::kVersion_4_9)) {
return serializeToArrayWithBothSyntaxes(array, explain);
}
@@ -1258,7 +1258,7 @@ intrusive_ptr<DocumentSource> DocumentSourceLookUp::createFromBson(
"$lookup with 'pipeline' may not specify 'localField' or 'foreignField'",
(localField.empty() && foreignField.empty()) ||
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kVersion49));
+ multiversion::FeatureCompatibilityVersion::kVersion_4_9));
if (localField.empty() && foreignField.empty()) {
// $lookup specified with only pipeline syntax.
diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
index eaee99d5b82..0df6d6d5927 100644
--- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp
+++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
@@ -78,14 +78,14 @@ REGISTER_DOCUMENT_SOURCE_WITH_MIN_VERSION(
LiteParsedDocumentSourceDefault::parse,
document_source_set_window_fields::createFromBson,
AllowedWithApiStrict::kNeverInVersion1,
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
REGISTER_DOCUMENT_SOURCE_WITH_MIN_VERSION(
_internalSetWindowFields,
LiteParsedDocumentSourceDefault::parse,
DocumentSourceInternalSetWindowFields::createFromBson,
AllowedWithApiStrict::kNeverInVersion1,
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
list<intrusive_ptr<DocumentSource>> document_source_set_window_fields::createFromBson(
BSONElement elem, const intrusive_ptr<ExpressionContext>& expCtx) {
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index 6ad34ec8740..77fb65b1eef 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -112,7 +112,7 @@ struct ParserRegistration {
Parser parser;
AllowedWithApiStrict allowedWithApiStrict;
AllowedWithClientType allowedWithClientType;
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion;
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion;
};
/**
@@ -175,7 +175,7 @@ void Expression::registerExpression(
Parser parser,
AllowedWithApiStrict allowedWithApiStrict,
AllowedWithClientType allowedWithClientType,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion) {
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion) {
auto op = parserMap.find(key);
massert(17064,
str::stream() << "Duplicate expression (" << key << ") registered.",
@@ -7395,7 +7395,7 @@ REGISTER_EXPRESSION_WITH_MIN_VERSION(
ExpressionGetField::parse,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
intrusive_ptr<Expression> ExpressionGetField::parse(ExpressionContext* const expCtx,
BSONElement expr,
@@ -7507,7 +7507,7 @@ REGISTER_EXPRESSION_WITH_MIN_VERSION(
ExpressionSetField::parse,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
// $unsetField is syntactic sugar for $setField where value is set to $$REMOVE.
REGISTER_EXPRESSION_WITH_MIN_VERSION(
@@ -7515,7 +7515,7 @@ REGISTER_EXPRESSION_WITH_MIN_VERSION(
ExpressionSetField::parse,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
intrusive_ptr<Expression> ExpressionSetField::parse(ExpressionContext* const expCtx,
BSONElement expr,
@@ -7651,7 +7651,7 @@ REGISTER_EXPRESSION_WITH_MIN_VERSION(
ExpressionTsSecond::parse,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
/* ------------------------- ExpressionTsIncrement ----------------------------- */
@@ -7675,7 +7675,7 @@ REGISTER_EXPRESSION_WITH_MIN_VERSION(
ExpressionTsIncrement::parse,
AllowedWithApiStrict::kNeverInVersion1,
AllowedWithClientType::kAny,
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
MONGO_INITIALIZER_GROUP(BeginExpressionRegistration, ("default"), ("EndExpressionRegistration"))
MONGO_INITIALIZER_GROUP(EndExpressionRegistration, ("BeginExpressionRegistration"), ())
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h
index 041c3cbe794..a0a2d08bdee 100644
--- a/src/mongo/db/pipeline/expression.h
+++ b/src/mongo/db/pipeline/expression.h
@@ -298,7 +298,7 @@ public:
Parser parser,
AllowedWithApiStrict allowedWithApiStrict,
AllowedWithClientType allowedWithClientType,
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version> requiredMinVersion);
+ boost::optional<multiversion::FeatureCompatibilityVersion> requiredMinVersion);
const auto& getChildren() const {
return _children;
diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h
index e923a9e9f46..8a5b82f0254 100644
--- a/src/mongo/db/pipeline/expression_context.h
+++ b/src/mongo/db/pipeline/expression_context.h
@@ -394,8 +394,7 @@ public:
long long subPipelineDepth = 0;
// If set, this will disallow use of features introduced in versions above the provided version.
- boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
- maxFeatureCompatibilityVersion;
+ boost::optional<multiversion::FeatureCompatibilityVersion> maxFeatureCompatibilityVersion;
// True if this ExpressionContext is used to parse a view definition pipeline.
bool isParsingViewDefinition = false;
diff --git a/src/mongo/db/pipeline/field_path.cpp b/src/mongo/db/pipeline/field_path.cpp
index 6a78400d9cc..120525e1230 100644
--- a/src/mongo/db/pipeline/field_path.cpp
+++ b/src/mongo/db/pipeline/field_path.cpp
@@ -100,7 +100,7 @@ void FieldPath::uassertValidFieldName(StringData fieldName) {
const auto dotsAndDollarsHint =
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50)
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)
? " Consider using $getField or $setField."
: "";
diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
index 165daf1332c..bfe7d621fc6 100644
--- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp
+++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
@@ -142,7 +142,7 @@ BSONObj genericTransformForShards(MutableDocument&& cmdForShards,
// TODO SERVER-52900 This code can be remove when we branch for the next LTS release.
if (serverGlobalParams.clusterRole == ClusterRole::ShardServer &&
!serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- ServerGlobalParams::FeatureCompatibility::Version::kVersion49)) {
+ multiversion::FeatureCompatibilityVersion::kVersion_4_9)) {
// A mixed version cluster. Use the old format to be sure it is understood.
auto [legacyRuntimeConstants, unusedSerializedVariables] =
expCtx->variablesParseState.transitionalCompatibilitySerialize(expCtx->variables);
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp
index 27aa7335f65..5820d2e2ab5 100644
--- a/src/mongo/db/repl/initial_syncer.cpp
+++ b/src/mongo/db/repl/initial_syncer.cpp
@@ -76,6 +76,7 @@
#include "mongo/util/system_clock_source.h"
#include "mongo/util/time_support.h"
#include "mongo/util/timer.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
namespace repl {
@@ -1060,7 +1061,7 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForBeginApplyingTimestamp(
BSONObjBuilder queryBob;
queryBob.append("find", NamespaceString::kServerConfigurationNamespace.coll());
auto filterBob = BSONObjBuilder(queryBob.subobjStart("filter"));
- filterBob.append("_id", FeatureCompatibilityVersionParser::kParameterName);
+ filterBob.append("_id", multiversion::kParameterName);
filterBob.done();
// As part of reading the FCV, we ensure the source node's all_durable timestamp has advanced
// to at least the timestamp of the last optime that we found in the lastOplogEntryFetcher.
@@ -1140,7 +1141,7 @@ void InitialSyncer::_fcvFetcherCallback(const StatusWith<Fetcher::QueryResponse>
lock,
Status(ErrorCodes::IncompatibleServerVersion,
str::stream() << "Sync source had unsafe feature compatibility version: "
- << FeatureCompatibilityVersionParser::toString(version)));
+ << multiversion::toString(version)));
return;
}
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index d026f108fb1..9661a12cdef 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -74,6 +74,7 @@
#include "mongo/util/fail_point.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/str.h"
+#include "mongo/util/version/releases.h"
#include "mongo/logv2/log.h"
#include "mongo/unittest/barrier.h"
@@ -666,14 +667,14 @@ void assertFCVRequest(RemoteCommandRequest request) {
<< request.toString();
ASSERT_EQUALS(NamespaceString::kServerConfigurationNamespace.coll(),
request.cmdObj.getStringField("find"));
- ASSERT_BSONOBJ_EQ(BSON("_id" << FeatureCompatibilityVersionParser::kParameterName),
+ ASSERT_BSONOBJ_EQ(BSON("_id" << multiversion::kParameterName),
request.cmdObj.getObjectField("filter"));
}
void InitialSyncerTest::processSuccessfulFCVFetcherResponseLastLTS() {
FeatureCompatibilityVersionDocument fcvDoc;
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS);
processSuccessfulFCVFetcherResponse({fcvDoc.toBSON()});
}
@@ -1925,7 +1926,7 @@ TEST_F(InitialSyncerTest,
InitialSyncerReturnsTooManyMatchingDocumentsWhenFCVFetcherReturnsMultipleDocuments) {
FeatureCompatibilityVersionDocument fcvDoc;
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS);
auto docs = {fcvDoc.toBSON(),
BSON("_id"
<< "other")};
@@ -1936,8 +1937,8 @@ TEST_F(InitialSyncerTest,
InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsUpgradeTargetVersion) {
FeatureCompatibilityVersionDocument fcvDoc;
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
- fcvDoc.setTargetVersion(ServerGlobalParams::FeatureCompatibility::kLatest);
+ fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS);
+ fcvDoc.setTargetVersion(multiversion::GenericFCV::kLatest);
runInitialSyncWithBadFCVResponse({fcvDoc.toBSON()}, ErrorCodes::IncompatibleServerVersion);
}
@@ -1945,15 +1946,16 @@ TEST_F(InitialSyncerTest,
InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsDowngradeTargetVersion) {
FeatureCompatibilityVersionDocument fcvDoc;
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
- fcvDoc.setTargetVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
- fcvDoc.setPreviousVersion(ServerGlobalParams::FeatureCompatibility::kLatest);
+ fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS);
+ fcvDoc.setTargetVersion(multiversion::GenericFCV::kLastLTS);
+ fcvDoc.setPreviousVersion(multiversion::GenericFCV::kLatest);
runInitialSyncWithBadFCVResponse({fcvDoc.toBSON()}, ErrorCodes::IncompatibleServerVersion);
}
TEST_F(InitialSyncerTest, InitialSyncerReturnsParseErrorWhenFCVFetcherReturnsNoVersion) {
- auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "targetVersion"
- << FeatureCompatibilityVersionParser::kLatest)};
+ // (Generic FCV reference): This FCV reference should exist across LTS binary versions.
+ auto docs = {BSON("_id" << multiversion::kParameterName << "targetVersion"
+ << multiversion::toString(multiversion::GenericFCV::kLatest))};
runInitialSyncWithBadFCVResponse(docs, ((ErrorCodes::Error)40414));
}
@@ -1986,7 +1988,7 @@ TEST_F(InitialSyncerTest, InitialSyncerSucceedsWhenFCVFetcherReturnsOldVersion)
FeatureCompatibilityVersionDocument fcvDoc;
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS);
processSuccessfulFCVFetcherResponse({fcvDoc.toBSON()});
}
@@ -2024,7 +2026,7 @@ TEST_F(
// This is what we want to test.
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
FeatureCompatibilityVersionDocument fcvDoc;
- fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS);
_mock
->expect([](auto& request) { return request["find"].str() == "system.version"; },
makeCursorResponse(
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 27d7901157d..1c48b3efd87 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -1153,7 +1153,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
requestNss == NamespaceString::kServerConfigurationNamespace) {
std::string oID;
auto status = bsonExtractStringField(o, "_id", &oID);
- if (status.isOK() && oID == FeatureCompatibilityVersionParser::kParameterName) {
+ if (status.isOK() && oID == multiversion::kParameterName) {
return Status(ErrorCodes::OplogOperationUnsupported,
str::stream() << "Applying operation on feature compatibility version "
"document not supported in initial sync: "
diff --git a/src/mongo/db/repl/oplog_applier_impl_test.cpp b/src/mongo/db/repl/oplog_applier_impl_test.cpp
index eef15241e05..9996da62a0e 100644
--- a/src/mongo/db/repl/oplog_applier_impl_test.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl_test.cpp
@@ -2366,7 +2366,7 @@ TEST_F(OplogApplierImplTest, FailOnInsertFCVDocument) {
ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_RECOVERING));
auto op = makeInsertDocumentOplogEntry(
- nextOpTime(), fcvNS, BSON("_id" << FeatureCompatibilityVersionParser::kParameterName));
+ nextOpTime(), fcvNS, BSON("_id" << multiversion::kParameterName));
ASSERT_EQUALS(runOpInitialSync(op), ErrorCodes::OplogOperationUnsupported);
}
diff --git a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp
index 9a2bc34390f..676622692c4 100644
--- a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp
@@ -176,8 +176,7 @@ void OplogApplierImplTest::setUp() {
// test fixture does not create a featureCompatibilityVersion document from which to initialize
// the server parameter.
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLatest);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
// This is necessary to generate ghost timestamps for index builds that are not 0, since 0 is an
// invalid timestamp.
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
index e996689c44b..18f89eb2eb3 100644
--- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
@@ -1901,7 +1901,7 @@ void TenantMigrationRecipientService::Instance::_compareRecipientAndDonorFCV() c
auto donorFCVbson =
_client->findOne(NamespaceString::kServerConfigurationNamespace.ns(),
- BSON("_id" << FeatureCompatibilityVersionParser::kParameterName),
+ BSON("_id" << multiversion::kParameterName),
Query(),
nullptr,
QueryOption_SecondaryOk,
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp
index 0b44a1155f3..a303a3cc442 100644
--- a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp
+++ b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp
@@ -445,9 +445,9 @@ protected:
* Sets the FCV on the donor so that it can respond to FCV requests appropriately.
* (Generic FCV reference): This FCV reference should exist across LTS binary versions.
*/
- void setDonorFCV(const TenantMigrationRecipientService::Instance* instance,
- ServerGlobalParams::FeatureCompatibility::Version version =
- ServerGlobalParams::FeatureCompatibility::kLatest) {
+ void setDonorFCV(
+ const TenantMigrationRecipientService::Instance* instance,
+ multiversion::FeatureCompatibilityVersion version = multiversion::GenericFCV::kLatest) {
auto fcvDoc = FeatureCompatibilityVersionDocument(version);
auto client = getClient(instance);
client->insert(NamespaceString::kServerConfigurationNamespace.ns(), fcvDoc.toBSON());
@@ -3203,8 +3203,7 @@ TEST_F(TenantMigrationRecipientServiceTest,
// Add an FCV value as if it was from a previous attempt, making sure we set a different
// version from the one we currently have.
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- initialStateDocument.setRecipientPrimaryStartingFCV(
- ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ initialStateDocument.setRecipientPrimaryStartingFCV(multiversion::GenericFCV::kLastLTS);
// Create and start the instance.
auto opCtx = makeOperationContext();
@@ -3257,7 +3256,7 @@ TEST_F(TenantMigrationRecipientServiceTest,
// Set the donor FCV to be different from 'latest'.
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
connFp->waitForTimesEntered(initialTimesEntered + 1);
- setDonorFCV(instance.get(), ServerGlobalParams::FeatureCompatibility::kLastContinuous);
+ setDonorFCV(instance.get(), multiversion::GenericFCV::kLastContinuous);
connFp->setMode(FailPoint::off);
// Wait for task completion failure.
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
index e47bebc388c..9a4223c1b30 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
@@ -56,6 +56,7 @@
#include "mongo/s/write_ops/batched_command_response.h"
#include "mongo/util/fail_point.h"
#include "mongo/util/scopeguard.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
namespace {
@@ -136,7 +137,7 @@ protected:
StatusWith<BSONObj> response,
BSONObj writeConcern) {
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- SetFeatureCompatibilityVersion fcvCmd(ServerGlobalParams::FeatureCompatibility::kLatest);
+ SetFeatureCompatibilityVersion fcvCmd(multiversion::GenericFCV::kLatest);
fcvCmd.setFromConfigServer(true);
fcvCmd.setDbName(NamespaceString::kAdminDb);
const auto setFcvObj = fcvCmd.toBSON(BSON("writeConcern" << writeConcern));
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
index 9be5bd179ee..525d3385b9a 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
@@ -80,6 +80,7 @@
#include "mongo/util/fail_point.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/str.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
namespace {
@@ -88,7 +89,6 @@ using CallbackHandle = executor::TaskExecutor::CallbackHandle;
using CallbackArgs = executor::TaskExecutor::CallbackArgs;
using RemoteCommandCallbackArgs = executor::TaskExecutor::RemoteCommandCallbackArgs;
using RemoteCommandCallbackFn = executor::TaskExecutor::RemoteCommandCallbackFn;
-using FeatureCompatibility = ServerGlobalParams::FeatureCompatibility;
const ReadPreferenceSetting kConfigReadSelector(ReadPreference::Nearest, TagSet{});
@@ -691,9 +691,9 @@ StatusWith<std::string> ShardingCatalogManager::addShard(
!fcvRegion->isUpgradingOrDowngrading());
// (Generic FCV reference): These FCV checks should exist across LTS binary versions.
- invariant(fcvRegion == FeatureCompatibility::kLatest ||
- fcvRegion == FeatureCompatibility::kLastContinuous ||
- fcvRegion == FeatureCompatibility::kLastLTS);
+ invariant(fcvRegion == multiversion::GenericFCV::kLatest ||
+ fcvRegion == multiversion::GenericFCV::kLastContinuous ||
+ fcvRegion == multiversion::GenericFCV::kLastLTS);
SetFeatureCompatibilityVersion setFcvCmd(fcvRegion->getVersion());
setFcvCmd.setDbName(NamespaceString::kAdminDb);
diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp
index 5eeb7f09c60..c9c070a4b0f 100644
--- a/src/mongo/db/s/create_collection_coordinator.cpp
+++ b/src/mongo/db/s/create_collection_coordinator.cpp
@@ -768,7 +768,7 @@ void CreateCollectionCoordinator::_commit(OperationContext* opCtx) {
// TODO: Remove condition once FCV 6.0 becomes last-lts
const auto& currentFCV = serverGlobalParams.featureCompatibility;
if (currentFCV.isGreaterThanOrEqualTo(
- ServerGlobalParams::FeatureCompatibility::Version::kUpgradingFrom50To51)) {
+ multiversion::FeatureCompatibilityVersion::kUpgradingFrom_5_0_To_5_1)) {
coll.setSupportingLongName(SupportingLongNameStatusEnum::kImplicitlyEnabled);
}
diff --git a/src/mongo/db/s/sharding_ddl_util.cpp b/src/mongo/db/s/sharding_ddl_util.cpp
index 85682a5925c..a5929f36d5e 100644
--- a/src/mongo/db/s/sharding_ddl_util.cpp
+++ b/src/mongo/db/s/sharding_ddl_util.cpp
@@ -313,7 +313,7 @@ void shardedRenameMetadata(OperationContext* opCtx,
// Only bump the epoch if the whole cluster is in FCV 5.0, so chunks do not contain epochs.
FixedFCVRegion fixedFCVRegion(opCtx);
if (serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo50)) {
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) {
fromCollType.setEpoch(OID::gen());
}
}
diff --git a/src/mongo/db/s/sharding_mongod_test_fixture.cpp b/src/mongo/db/s/sharding_mongod_test_fixture.cpp
index 3760b7e0661..f81cda6ba08 100644
--- a/src/mongo/db/s/sharding_mongod_test_fixture.cpp
+++ b/src/mongo/db/s/sharding_mongod_test_fixture.cpp
@@ -134,8 +134,7 @@ ShardingMongodTestFixture::ShardingMongodTestFixture() {
// Set the highest FCV because otherwise it defaults to the lower FCV. This way we default to
// testing this release's code, not backwards compatibility code.
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLatest);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
}
ShardingMongodTestFixture::~ShardingMongodTestFixture() = default;
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h
index 14a4416f0a8..d00310d7df2 100644
--- a/src/mongo/db/server_options.h
+++ b/src/mongo/db/server_options.h
@@ -36,6 +36,7 @@
#include "mongo/platform/process_id.h"
#include "mongo/stdx/variant.h"
#include "mongo/util/net/cidr.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
@@ -139,6 +140,8 @@ struct ServerGlobalParams {
static constexpr bool kIsLTSBinaryVersion = false;
struct FeatureCompatibility {
+ using FCV = multiversion::FeatureCompatibilityVersion;
+
/**
* The combination of the fields (version, targetVersion, previousVersion) in the
* featureCompatibilityVersion document in the server configuration collection
@@ -175,89 +178,50 @@ struct ServerGlobalParams {
* will return the default (kUnsetDefault{LTS}Behavior).
*
*/
- enum class Version {
- // The order of these enums matter: sort by (version, targetVersion, previousVersion).
- kInvalid,
- kVersion44, // To be removed once old feature flags are deleted
- kVersion47, // To be removed once old feature flags are deleted
- kVersion48, // To be removed once old feature flags are deleted
- kVersion49, // To be removed once old feature flags are deleted
- kFullyDowngradedTo44, // To be removed once old feature flags are deleted
- kDowngradingFrom50To49, // To be removed once old feature flags are deleted
- kDowngradingFrom50To44, // To be removed once old feature flags are deleted
- kUpgradingFrom44To50, // To be removed once old feature flags are deleted
- kUpgradingFrom44To47, // To be removed once old feature flags are deleted
- kUpgradingFrom49To50, // To be removed once old feature flags are deleted
- kUnsetDefault50Behavior,
- kFullyDowngradedTo50, // { version: 5.0 }
- kDowngradingFrom51To50, // { version: 5.0, targetVersion: 5.0, previousVersion: 5.1 }
- kUpgradingFrom50To51, // { version: 5.0, targetVersion: 5.1 }
- kVersion51, // { version: 5.1 }
- };
-
- // These constants should only be used for generic FCV references. Generic references are
- // FCV references that are expected to exist across LTS binary versions.
- static constexpr Version kLatest = Version::kVersion51;
- static constexpr Version kLastContinuous = Version::kFullyDowngradedTo50;
- static constexpr Version kLastLTS = Version::kFullyDowngradedTo50;
-
- // These constants should only be used for generic FCV references. Generic references are
- // FCV references that are expected to exist across LTS binary versions.
- // NOTE: DO NOT USE THEM FOR REGULAR FCV CHECKS.
- static constexpr Version kUpgradingFromLastLTSToLatest = Version::kUpgradingFrom50To51;
- static constexpr Version kUpgradingFromLastContinuousToLatest =
- Version::kUpgradingFrom50To51;
- static constexpr Version kDowngradingFromLatestToLastLTS = Version::kDowngradingFrom51To50;
- static constexpr Version kDowngradingFromLatestToLastContinuous =
- Version::kDowngradingFrom51To50;
- // kUpgradingFromLastLTSToLastContinuous is only ever set to a valid FCV when
- // kLastLTS and kLastContinuous are not equal. Otherwise, this value should be set to
- // kInvalid.
- static constexpr Version kUpgradingFromLastLTSToLastContinuous = Version::kInvalid;
/**
* On startup, the featureCompatibilityVersion may not have been explicitly set yet. This
* exposes the actual state of the featureCompatibilityVersion if it is uninitialized.
*/
const bool isVersionInitialized() const {
- return _version.load() != Version::kUnsetDefault50Behavior;
+ return _version.load() != FCV::kUnsetDefaultLastLTSBehavior;
}
/**
* This safe getter for the featureCompatibilityVersion parameter ensures the parameter has
* been initialized with a meaningful value.
*/
- const Version getVersion() const {
+ const FCV getVersion() const {
invariant(isVersionInitialized());
return _version.load();
}
- bool isLessThanOrEqualTo(Version version, Version* versionReturn = nullptr) const {
- Version currentVersion = getVersion();
+ bool isLessThanOrEqualTo(FCV version, FCV* versionReturn = nullptr) const {
+ auto currentVersion = getVersion();
if (versionReturn != nullptr) {
*versionReturn = currentVersion;
}
return currentVersion <= version;
}
- bool isGreaterThanOrEqualTo(Version version, Version* versionReturn = nullptr) const {
- Version currentVersion = getVersion();
+ bool isGreaterThanOrEqualTo(FCV version, FCV* versionReturn = nullptr) const {
+ auto currentVersion = getVersion();
if (versionReturn != nullptr) {
*versionReturn = currentVersion;
}
return currentVersion >= version;
}
- bool isLessThan(Version version, Version* versionReturn = nullptr) const {
- Version currentVersion = getVersion();
+ bool isLessThan(FCV version, FCV* versionReturn = nullptr) const {
+ auto currentVersion = getVersion();
if (versionReturn != nullptr) {
*versionReturn = currentVersion;
}
return currentVersion < version;
}
- bool isGreaterThan(Version version, Version* versionReturn = nullptr) const {
- Version currentVersion = getVersion();
+ bool isGreaterThan(FCV version, FCV* versionReturn = nullptr) const {
+ auto currentVersion = getVersion();
if (versionReturn != nullptr) {
*versionReturn = currentVersion;
}
@@ -265,23 +229,27 @@ struct ServerGlobalParams {
}
// This function is to be used for generic FCV references only, and not for FCV-gating.
- bool isUpgradingOrDowngrading(boost::optional<Version> version = boost::none) const {
+ bool isUpgradingOrDowngrading(boost::optional<FCV> version = boost::none) const {
if (version == boost::none) {
version = getVersion();
}
- return version != kLatest && version != kLastContinuous && version != kLastLTS;
+
+ // (Generic FCV reference): This FCV reference should exist across LTS binary versions.
+ return version != multiversion::GenericFCV::kLatest &&
+ version != multiversion::GenericFCV::kLastContinuous &&
+ version != multiversion::GenericFCV::kLastLTS;
}
void reset() {
- _version.store(Version::kUnsetDefault50Behavior);
+ _version.store(FCV::kUnsetDefaultLastLTSBehavior);
}
- void setVersion(Version version) {
+ void setVersion(FCV version) {
return _version.store(version);
}
private:
- AtomicWord<Version> _version{Version::kUnsetDefault50Behavior};
+ AtomicWord<FCV> _version{FCV::kUnsetDefaultLastLTSBehavior};
} mutableFeatureCompatibility;
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index 8ad042a17fd..8b85198cd32 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -216,7 +216,7 @@ public:
// TODO: SERVER-58743: Remove following 'if' block.
if (auto& fcv = serverGlobalParams.featureCompatibility;
!fcv.isVersionInitialized() ||
- fcv.isLessThan(FeatureCompatibilityParams::Version::kVersion51)) {
+ fcv.isLessThan(multiversion::FeatureCompatibilityVersion::kVersion_5_1)) {
// For commands from mongos, append some info to help getLastError(w) work.
rpc::ShardingMetadata(lastOpTimeFromClient, replCoord->getElectionId())
.writeToMetadata(metadataBob)
diff --git a/src/mongo/db/startup_recovery.cpp b/src/mongo/db/startup_recovery.cpp
index 2e236863068..655af5e36dd 100644
--- a/src/mongo/db/startup_recovery.cpp
+++ b/src/mongo/db/startup_recovery.cpp
@@ -100,7 +100,7 @@ Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx
LOGV2(4926905,
"Re-creating featureCompatibilityVersion document that was deleted. Creating new "
"document with last LTS version.",
- "version"_attr = FeatureCompatibilityVersionParser::kLastLTS);
+ "version"_attr = multiversion::toString(multiversion::GenericFCV::kLastLTS));
uassertStatusOK(
createCollection(opCtx, fcvNss.db().toString(), BSON("create" << fcvNss.coll())));
}
@@ -113,19 +113,17 @@ Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx
BSONObj featureCompatibilityVersion;
if (!Helpers::findOne(opCtx,
fcvColl,
- BSON("_id" << FeatureCompatibilityVersionParser::kParameterName),
+ BSON("_id" << multiversion::kParameterName),
featureCompatibilityVersion)) {
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
LOGV2(21000,
"Re-creating featureCompatibilityVersion document that was deleted. Creating new "
- "document with version "
- "{FeatureCompatibilityVersionParser_kLastLTS}.",
- "Re-creating featureCompatibilityVersion document that was deleted",
- "version"_attr = FeatureCompatibilityVersionParser::kLastLTS);
+ "document with version ",
+ "version"_attr = multiversion::toString(multiversion::GenericFCV::kLastLTS));
FeatureCompatibilityVersionDocument fcvDoc;
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS);
writeConflictRetry(opCtx, "insertFCVDocument", fcvNss.ns(), [&] {
WriteUnitOfWork wunit(opCtx);
@@ -136,10 +134,8 @@ Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx
});
}
- invariant(Helpers::findOne(opCtx,
- fcvColl,
- BSON("_id" << FeatureCompatibilityVersionParser::kParameterName),
- featureCompatibilityVersion));
+ invariant(Helpers::findOne(
+ opCtx, fcvColl, BSON("_id" << multiversion::kParameterName), featureCompatibilityVersion));
return Status::OK();
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index 1ad645908af..449fbc4bb55 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -151,7 +151,7 @@ bool WiredTigerFileVersion::shouldDowngrade(bool readOnly,
}
if (serverGlobalParams.featureCompatibility.isGreaterThan(
- ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44)) {
+ multiversion::FeatureCompatibilityVersion::kVersion_4_4)) {
// Only consider downgrading when FCV is set to kFullyDowngraded.
// (This FCV gate must remain across binary version releases.)
return false;
diff --git a/src/mongo/db/update/pipeline_executor.cpp b/src/mongo/db/update/pipeline_executor.cpp
index c2e77fb1e90..ac6df9ca086 100644
--- a/src/mongo/db/update/pipeline_executor.cpp
+++ b/src/mongo/db/update/pipeline_executor.cpp
@@ -104,7 +104,7 @@ UpdateExecutor::ApplyResult PipelineExecutor::applyUpdate(ApplyParams applyParam
bool allowTopLevelDollarPrefixedFields =
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
auto ret = ObjectReplaceExecutor::applyReplacementUpdate(
applyParams, transformedDoc, transformedDocHasIdField, allowTopLevelDollarPrefixedFields);
diff --git a/src/mongo/db/update/storage_validation.cpp b/src/mongo/db/update/storage_validation.cpp
index 444637470f3..3e04bf45f35 100644
--- a/src/mongo/db/update/storage_validation.cpp
+++ b/src/mongo/db/update/storage_validation.cpp
@@ -115,7 +115,7 @@ void validateDollarPrefixElement(mutablebson::ConstElement elem) {
const auto replaceWithHint =
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50)
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)
? "' is not allowed in the context of an update's replacement document. Consider using "
"an aggregation pipeline with $replaceWith."
: "' is not valid for storage.";
@@ -140,7 +140,7 @@ Status storageValidIdField(const mongo::BSONElement& element) {
if (!status.isOK() && status.code() == ErrorCodes::DollarPrefixedFieldName &&
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50)) {
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) {
return Status(status.code(),
str::stream() << "_id fields may not contain '$'-prefixed fields: "
<< status.reason());
@@ -203,7 +203,7 @@ void storageValid(mutablebson::ConstElement elem,
const bool dotsAndDollarsFeatureEnabled =
serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- FeatureCompatibilityParams::Version::kFullyDowngradedTo50);
+ multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
const bool checkFields = !dotsAndDollarsFeatureEnabled || checkTopLevelFields;
auto fieldName = elem.getFieldName();
diff --git a/src/mongo/db/views/view_catalog.cpp b/src/mongo/db/views/view_catalog.cpp
index 835bcfddc76..e84d0c0fa69 100644
--- a/src/mongo/db/views/view_catalog.cpp
+++ b/src/mongo/db/views/view_catalog.cpp
@@ -455,10 +455,10 @@ StatusWith<stdx::unordered_set<NamespaceString>> ViewCatalog::validatePipeline(
// primary, ban the use of new agg features introduced in kLatest to prevent them from being
// persisted in the catalog.
// (Generic FCV reference): This FCV check should exist across LTS binary versions.
- ServerGlobalParams::FeatureCompatibility::Version fcv;
+ multiversion::FeatureCompatibilityVersion fcv;
if (serverGlobalParams.validateFeaturesAsPrimary.load() &&
- serverGlobalParams.featureCompatibility.isLessThan(
- ServerGlobalParams::FeatureCompatibility::kLatest, &fcv)) {
+ serverGlobalParams.featureCompatibility.isLessThan(multiversion::GenericFCV::kLatest,
+ &fcv)) {
expCtx->maxFeatureCompatibilityVersion = fcv;
}
diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp
index 019544a8b03..c34817f10f4 100644
--- a/src/mongo/dbtests/dbtests.cpp
+++ b/src/mongo/dbtests/dbtests.cpp
@@ -188,8 +188,7 @@ int dbtestsMain(int argc, char** argv) {
mongo::runGlobalInitializersOrDie(std::vector<std::string>(argv, argv + argc));
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLatest);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
repl::ReplSettings replSettings;
replSettings.setOplogSizeBytes(10 * 1024 * 1024);
setGlobalServiceContext(ServiceContext::make());
diff --git a/src/mongo/idl/basic_types.idl b/src/mongo/idl/basic_types.idl
index c0037bbb446..4a5349ca353 100644
--- a/src/mongo/idl/basic_types.idl
+++ b/src/mongo/idl/basic_types.idl
@@ -222,7 +222,7 @@ types:
description: >-
Ensures that the version strings in featureCompatibilityVersion documents
serialize/deserialize to a fixed set of string values
- cpp_type: "ServerGlobalParams::FeatureCompatibility::Version"
+ cpp_type: "multiversion::FeatureCompatibilityVersion"
serializer: "::mongo::FeatureCompatibilityVersionParser::serializeVersion"
deserializer: "mongo::FeatureCompatibilityVersionParser::parseVersion"
diff --git a/src/mongo/idl/feature_flag.cpp b/src/mongo/idl/feature_flag.cpp
index b02d110ec8b..4669bf0466e 100644
--- a/src/mongo/idl/feature_flag.cpp
+++ b/src/mongo/idl/feature_flag.cpp
@@ -30,12 +30,13 @@
#include "mongo/idl/feature_flag.h"
#include "mongo/db/commands/feature_compatibility_version_parser.h"
#include "mongo/util/debug_util.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
// (Generic FCV reference): feature flag support
FeatureFlag::FeatureFlag(bool enabled, StringData versionString)
- : _enabled(enabled), _version(ServerGlobalParams::FeatureCompatibility::kLatest) {
+ : _enabled(enabled), _version(multiversion::GenericFCV::kLatest) {
// Verify the feature flag invariants. IDL binder verifies these hold but we add these checks to
// prevent incorrect direct instantiation.
@@ -67,7 +68,7 @@ bool FeatureFlag::isEnabledAndIgnoreFCV() const {
return _enabled;
}
-ServerGlobalParams::FeatureCompatibility::Version FeatureFlag::getVersion() const {
+multiversion::FeatureCompatibilityVersion FeatureFlag::getVersion() const {
uassert(5111001, "Feature Flag is not enabled, cannot retrieve version", _enabled);
return _version;
diff --git a/src/mongo/idl/feature_flag.h b/src/mongo/idl/feature_flag.h
index 0a5bf3c6ca0..ea097637606 100644
--- a/src/mongo/idl/feature_flag.h
+++ b/src/mongo/idl/feature_flag.h
@@ -36,6 +36,7 @@
#include "mongo/db/server_options.h"
#include "mongo/idl/server_parameter.h"
#include "mongo/idl/server_parameter_with_storage.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
@@ -72,14 +73,14 @@ public:
*
* Throws if feature is not enabled.
*/
- ServerGlobalParams::FeatureCompatibility::Version getVersion() const;
+ multiversion::FeatureCompatibilityVersion getVersion() const;
private:
void set(bool enabled);
private:
bool _enabled;
- ServerGlobalParams::FeatureCompatibility::Version _version;
+ multiversion::FeatureCompatibilityVersion _version;
};
/**
diff --git a/src/mongo/idl/feature_flag_test.cpp b/src/mongo/idl/feature_flag_test.cpp
index 7431a7e9d18..e4a41e48c67 100644
--- a/src/mongo/idl/feature_flag_test.cpp
+++ b/src/mongo/idl/feature_flag_test.cpp
@@ -84,20 +84,19 @@ TEST(IDLFeatureFlag, Basic) {
ASSERT(feature_flags::gFeatureFlagToaster.isEnabledAndIgnoreFCV() == true);
ASSERT_NOT_OK(featureFlagToaster->setFromString("alpha"));
- ASSERT(feature_flags::gFeatureFlagToaster.getVersion() ==
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ // (Generic FCV reference): feature flag test
+ ASSERT(feature_flags::gFeatureFlagToaster.getVersion() == multiversion::GenericFCV::kLatest);
}
// Verify getVersion works correctly when enabled and not enabled
TEST_F(FeatureFlagTest, Version) {
- ASSERT(feature_flags::gFeatureFlagBlender.getVersion() ==
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ // (Generic FCV reference): feature flag test
+ ASSERT(feature_flags::gFeatureFlagBlender.getVersion() == multiversion::GenericFCV::kLatest);
// NOTE: if you are hitting this assertion, the version in feature_flag_test.idl may need to be
// changed to match the current kLastLTS
// (Generic FCV reference): feature flag test
- ASSERT(feature_flags::gFeatureFlagSpoon.getVersion() ==
- ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ ASSERT(feature_flags::gFeatureFlagSpoon.getVersion() == multiversion::GenericFCV::kLastLTS);
ASSERT_OK(_featureFlagBlender->setFromString("false"));
ASSERT(feature_flags::gFeatureFlagBlender.isEnabledAndIgnoreFCV() == false);
@@ -137,8 +136,8 @@ TEST_F(FeatureFlagTest, ServerStatus) {
TEST_F(FeatureFlagTest, IsEnabledTrue) {
// Test FCV checks with enabled flag
// Test newest version
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ // (Generic FCV reference): feature flag test
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
ASSERT_TRUE(
feature_flags::gFeatureFlagBlender.isEnabled(serverGlobalParams.featureCompatibility));
@@ -147,8 +146,7 @@ TEST_F(FeatureFlagTest, IsEnabledTrue) {
// Test oldest version
// (Generic FCV reference): feature flag test
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLastLTS);
ASSERT_FALSE(
feature_flags::gFeatureFlagBlender.isEnabled(serverGlobalParams.featureCompatibility));
@@ -163,8 +161,8 @@ TEST_F(FeatureFlagTest, IsEnabledFalse) {
ASSERT_OK(_featureFlagBlender->setFromString("false"));
ASSERT_OK(_featureFlagSpoon->setFromString("false"));
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::Version::kVersion51);
+ // (Generic FCV reference): feature flag test
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
ASSERT_FALSE(
feature_flags::gFeatureFlagBlender.isEnabled(serverGlobalParams.featureCompatibility));
@@ -173,8 +171,7 @@ TEST_F(FeatureFlagTest, IsEnabledFalse) {
// Test oldest version
// (Generic FCV reference): feature flag test
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLastLTS);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLastLTS);
ASSERT_FALSE(
feature_flags::gFeatureFlagBlender.isEnabled(serverGlobalParams.featureCompatibility));
diff --git a/src/mongo/idl/idl_parser.h b/src/mongo/idl/idl_parser.h
index df5d788a1b3..a9df8299e3b 100644
--- a/src/mongo/idl/idl_parser.h
+++ b/src/mongo/idl/idl_parser.h
@@ -103,9 +103,8 @@ auto idlPreparsedValue(stdx::type_identity<T>) {
* TODO(SERVER-50101): Remove 'FeatureCompatibility::Version' once IDL supports
* a command cpp_type of C++ enum.
*/
-inline auto idlPreparsedValue(
- stdx::type_identity<ServerGlobalParams::FeatureCompatibility::Version>) {
- return ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault50Behavior;
+inline auto idlPreparsedValue(stdx::type_identity<multiversion::FeatureCompatibilityVersion>) {
+ return multiversion::FeatureCompatibilityVersion::kUnsetDefaultLastLTSBehavior;
}
} // namespace preparsed_value_adl_barrier
diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp
index eb7b18671de..302c469afae 100644
--- a/src/mongo/s/client/shard_registry.cpp
+++ b/src/mongo/s/client/shard_registry.cpp
@@ -61,7 +61,7 @@ const Seconds kRefreshPeriod(30);
bool useActualTopologyTime() {
return serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- ServerGlobalParams::FeatureCompatibility::Version::kVersion47);
+ multiversion::FeatureCompatibilityVersion::kVersion_4_7);
}
} // namespace
diff --git a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
index 800d3aec6a8..d6893ec1083 100644
--- a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
+++ b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
@@ -38,6 +38,7 @@
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"
#include "mongo/util/str.h"
+#include "mongo/util/version/releases.h"
namespace mongo {
@@ -57,7 +58,7 @@ class SetFeatureCompatibilityVersionCmd final
: public TypedCommand<SetFeatureCompatibilityVersionCmd> {
public:
using Request = SetFeatureCompatibilityVersion;
- using FCVP = FeatureCompatibilityVersionParser;
+ using GenericFCV = multiversion::GenericFCV;
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
@@ -70,15 +71,18 @@ public:
std::string help() const override {
std::stringstream h;
h << "Set the featureCompatibilityVersion used by this cluster. If set to '"
- << FCVP::kLastLTS << "', then features introduced in versions greater than '"
- << FCVP::kLastLTS << "' will be disabled";
- if (FCVP::kLastContinuous != FCVP::kLastLTS) {
- h << " If set to '" << FCVP::kLastContinuous << "', then features introduced in '"
- << FCVP::kLatest << "' will be disabled.";
+ << multiversion::toString(GenericFCV::kLastLTS)
+ << "', then features introduced in versions greater than '"
+ << multiversion::toString(GenericFCV::kLastLTS) << "' will be disabled";
+ if (GenericFCV::kLastContinuous != GenericFCV::kLastLTS) {
+ h << " If set to '" << multiversion::toString(GenericFCV::kLastContinuous)
+ << "', then features introduced in '" << multiversion::toString(GenericFCV::kLatest)
+ << "' will be disabled.";
}
- h << " If set to '" << FCVP::kLatest << "', then '" << FCVP::kLatest
+ h << " If set to '" << multiversion::toString(GenericFCV::kLatest) << "', then '"
+ << multiversion::toString(GenericFCV::kLatest)
<< "' features are enabled, and all nodes in the cluster must be binary version "
- << FCVP::kLatest << ". See "
+ << multiversion::toString(GenericFCV::kLatest) << ". See "
<< feature_compatibility_version_documentation::kCompatibilityLink << ".";
return h.str();
}
diff --git a/src/mongo/s/mongos_main.cpp b/src/mongo/s/mongos_main.cpp
index 2fe4e84cb1f..0de9e5c87c9 100644
--- a/src/mongo/s/mongos_main.cpp
+++ b/src/mongo/s/mongos_main.cpp
@@ -855,8 +855,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersionLatest,
("EndStartupOptionStorage"))
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
(InitializerContext* context) {
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLatest);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
}
#ifdef MONGO_CONFIG_SSL
diff --git a/src/mongo/shell/mongo_main.cpp b/src/mongo/shell/mongo_main.cpp
index b5e5e01a6c7..6d95fca1ec7 100644
--- a/src/mongo/shell/mongo_main.cpp
+++ b/src/mongo/shell/mongo_main.cpp
@@ -119,7 +119,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersionLatest,
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
(InitializerContext* context) {
mongo::serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLatest);
+ multiversion::GenericFCV::kLatest);
}
MONGO_INITIALIZER_WITH_PREREQUISITES(WireSpec, ("EndStartupOptionSetup"))(InitializerContext*) {
diff --git a/src/mongo/unittest/ensure_fcv.h b/src/mongo/unittest/ensure_fcv.h
index a0e6e19ed8d..a1015b946b6 100644
--- a/src/mongo/unittest/ensure_fcv.h
+++ b/src/mongo/unittest/ensure_fcv.h
@@ -40,7 +40,7 @@ namespace unittest {
*/
class EnsureFCV {
public:
- using Version = ServerGlobalParams::FeatureCompatibility::Version;
+ using Version = multiversion::FeatureCompatibilityVersion;
EnsureFCV(Version version)
: _origVersion(serverGlobalParams.featureCompatibility.getVersion()) {
serverGlobalParams.mutableFeatureCompatibility.setVersion(version);
diff --git a/src/mongo/unittest/unittest.cpp b/src/mongo/unittest/unittest.cpp
index 35626c38b20..233bb38f3ed 100644
--- a/src/mongo/unittest/unittest.cpp
+++ b/src/mongo/unittest/unittest.cpp
@@ -59,6 +59,7 @@
#include "mongo/util/signal_handlers_synchronous.h"
#include "mongo/util/stacktrace.h"
#include "mongo/util/timer.h"
+#include "mongo/util/version/releases.h"
namespace mongo::unittest {
namespace {
@@ -156,8 +157,7 @@ namespace {
// with a meaningful value will trigger failures as of SERVER-32630.
// (Generic FCV reference): This FCV reference should exist across LTS binary versions.
void setUpFCV() {
- serverGlobalParams.mutableFeatureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::kLatest);
+ serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
}
void tearDownFCV() {
serverGlobalParams.mutableFeatureCompatibility.reset();