From 6a2c556dfaed34e641b64469d1de34dc88d36ec9 Mon Sep 17 00:00:00 2001 From: Bernard Gorman Date: Tue, 13 Aug 2019 16:09:24 +0100 Subject: SERVER-41230 Update FCV constants throughout server code following 4.2 branch SERVER-42162 Update Execution-related generic upgrade/downgrade references SERVER-42642 Update Replication-related generic upgrade/downgrade references SERVER-42592 Update Sharding-related generic upgrade/downgrade references SERVER-42794 Update Query-related generic upgrade/downgrade references SERVER-41545 Bump wire protocol version for 4.4 --- src/mongo/db/catalog/coll_mod.cpp | 6 +- src/mongo/db/catalog/database_impl.cpp | 6 +- src/mongo/db/catalog/index_key_validate.cpp | 9 -- src/mongo/db/catalog/index_spec_validate_test.cpp | 26 ------ src/mongo/db/catalog/multi_index_block.cpp | 8 -- .../db/commands/feature_compatibility_version.cpp | 56 +++++------ .../db/commands/feature_compatibility_version.h | 13 ++- ...eature_compatibility_version_command_parser.cpp | 8 +- .../feature_compatibility_version_parser.cpp | 32 +++---- .../feature_compatibility_version_parser.h | 22 ++--- .../set_feature_compatibility_version_command.cpp | 40 ++++---- src/mongo/db/index_builds_coordinator.cpp | 9 +- src/mongo/db/repair_database_and_check_version.cpp | 20 ++-- src/mongo/db/repl/initial_syncer.cpp | 4 +- src/mongo/db/repl/initial_syncer_test.cpp | 104 ++++++++++----------- src/mongo/db/repl/replication_coordinator_impl.cpp | 2 +- src/mongo/db/repl/replication_recovery.cpp | 8 +- src/mongo/db/repl/replication_recovery_test.cpp | 3 +- src/mongo/db/repl/sync_tail_test_fixture.cpp | 2 +- src/mongo/db/repl_index_build_state.h | 10 +- .../sharding_catalog_manager_add_shard_test.cpp | 3 +- .../sharding_catalog_manager_shard_operations.cpp | 44 +++------ src/mongo/db/server_options.h | 54 +++++------ .../db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 17 ++-- .../db/storage/wiredtiger/wiredtiger_kv_engine.h | 2 +- src/mongo/db/views/view_catalog.cpp | 6 +- src/mongo/db/wire_version.h | 5 +- src/mongo/dbtests/dbtests.cpp | 2 +- ...uster_set_feature_compatibility_version_cmd.cpp | 14 +-- src/mongo/s/server.cpp | 5 +- src/mongo/s/sharding_mongod_test_fixture.cpp | 3 +- src/mongo/shell/dbshell.cpp | 5 +- src/mongo/shell/shardingtest.js | 2 +- src/mongo/unittest/unittest.cpp | 2 +- 34 files changed, 243 insertions(+), 309 deletions(-) (limited to 'src/mongo') diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index c881c88df99..0d51e406f6e 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -171,14 +171,14 @@ StatusWith parseCollModRequest(OperationContext* opCtx, // Save this to a variable to avoid reading the atomic variable multiple times. const auto currentFCV = serverGlobalParams.featureCompatibility.getVersion(); - // If the feature compatibility version is not 4.2, and we are validating features as - // master, ban the use of new agg features introduced in 4.2 to prevent them from being + // If the feature compatibility version is not 4.4, and we are validating features as + // master, ban the use of new agg features introduced in 4.4 to prevent them from being // persisted in the catalog. boost::optional maxFeatureCompatibilityVersion; if (serverGlobalParams.validateFeaturesAsMaster.load() && currentFCV != - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { maxFeatureCompatibilityVersion = currentFCV; } auto statusW = coll->parseValidator(opCtx, diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index 467651ae53d..ae069818043 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -833,11 +833,11 @@ Status DatabaseImpl::userCreateNS(OperationContext* opCtx, // Save this to a variable to avoid reading the atomic variable multiple times. const auto currentFCV = serverGlobalParams.featureCompatibility.getVersion(); - // If the feature compatibility version is not 4.2, and we are validating features as - // master, ban the use of new agg features introduced in 4.2 to prevent them from being + // If the feature compatibility version is not 4.4, and we are validating features as + // master, ban the use of new agg features introduced in 4.4 to prevent them from being // persisted in the catalog. if (serverGlobalParams.validateFeaturesAsMaster.load() && - currentFCV != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { + currentFCV != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { expCtx->maxFeatureCompatibilityVersion = currentFCV; } auto statusWithMatcher = diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp index 83c6812f5b1..4b1f35ce1a6 100644 --- a/src/mongo/db/catalog/index_key_validate.cpp +++ b/src/mongo/db/catalog/index_key_validate.cpp @@ -305,15 +305,6 @@ StatusWith validateIndexSpec( << "Values in the index key pattern cannot be empty strings"}; } } - - if ((featureCompatibility.getVersion() < - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) && - (IndexNames::findPluginName(indexSpec.getObjectField( - IndexDescriptor::kKeyPatternFieldName)) == IndexNames::WILDCARD)) { - return {ErrorCodes::CannotCreateIndex, - str::stream() - << "Wildcard indexes require feature compatibility version 4.2"}; - } hasKeyPatternField = true; } else if (IndexDescriptor::kIndexNameFieldName == indexSpecElemFieldName) { if (indexSpecElem.type() != BSONType::String) { diff --git a/src/mongo/db/catalog/index_spec_validate_test.cpp b/src/mongo/db/catalog/index_spec_validate_test.cpp index cb2d66df78f..72343c238f7 100644 --- a/src/mongo/db/catalog/index_spec_validate_test.cpp +++ b/src/mongo/db/catalog/index_spec_validate_test.cpp @@ -44,7 +44,6 @@ #include "mongo/db/query/query_knobs_gen.h" #include "mongo/db/query/query_test_service_context.h" #include "mongo/db/server_options.h" -#include "mongo/unittest/ensure_fcv.h" #include "mongo/unittest/unittest.h" namespace mongo { @@ -53,7 +52,6 @@ namespace { using index_key_validate::validateIdIndexSpec; using index_key_validate::validateIndexSpec; using index_key_validate::validateIndexSpecCollation; -using unittest::EnsureFCV; constexpr OperationContext* kDefaultOpCtx = nullptr; @@ -554,7 +552,6 @@ TEST(IndexSpecPartialFilterTest, AcceptsValidPartialFilterExpression) { } TEST(IndexSpecWildcard, SucceedsWithInclusion) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" @@ -565,7 +562,6 @@ TEST(IndexSpecWildcard, SucceedsWithInclusion) { } TEST(IndexSpecWildcard, SucceedsWithExclusion) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" @@ -576,7 +572,6 @@ TEST(IndexSpecWildcard, SucceedsWithExclusion) { } TEST(IndexSpecWildcard, SucceedsWithExclusionIncludingId) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" @@ -587,7 +582,6 @@ TEST(IndexSpecWildcard, SucceedsWithExclusionIncludingId) { } TEST(IndexSpecWildcard, SucceedsWithInclusionExcludingId) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" @@ -598,7 +592,6 @@ TEST(IndexSpecWildcard, SucceedsWithInclusionExcludingId) { } TEST(IndexSpecWildcard, FailsWithInclusionExcludingIdSubfield) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" @@ -609,7 +602,6 @@ TEST(IndexSpecWildcard, FailsWithInclusionExcludingIdSubfield) { } TEST(IndexSpecWildcard, FailsWithExclusionIncludingIdSubfield) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" @@ -619,19 +611,7 @@ TEST(IndexSpecWildcard, FailsWithExclusionIncludingIdSubfield) { ASSERT_EQ(result.getStatus().code(), 40178); } -TEST(IndexSpecWildcard, FailsWithImproperFeatureCompatabilityVersion) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); - serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42); - auto result = validateIndexSpec(kDefaultOpCtx, - BSON("key" << BSON("$**" << 1) << "name" - << "indexName"), - serverGlobalParams.featureCompatibility); - ASSERT_EQ(result.getStatus().code(), ErrorCodes::CannotCreateIndex); -} - TEST(IndexSpecWildcard, FailsWithMixedProjection) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" @@ -642,7 +622,6 @@ TEST(IndexSpecWildcard, FailsWithMixedProjection) { } TEST(IndexSpecWildcard, FailsWithComputedFieldsInProjection) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" @@ -654,7 +633,6 @@ TEST(IndexSpecWildcard, FailsWithComputedFieldsInProjection) { } TEST(IndexSpecWildcard, FailsWhenProjectionPluginNotWildcard) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("a" << 1) << "name" << "indexName" @@ -664,7 +642,6 @@ TEST(IndexSpecWildcard, FailsWhenProjectionPluginNotWildcard) { } TEST(IndexSpecWildcard, FailsWhenProjectionIsNotAnObject) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" @@ -674,7 +651,6 @@ TEST(IndexSpecWildcard, FailsWhenProjectionIsNotAnObject) { } TEST(IndexSpecWildcard, FailsWithEmptyProjection) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" @@ -684,7 +660,6 @@ TEST(IndexSpecWildcard, FailsWithEmptyProjection) { } TEST(IndexSpecWildcard, FailsWhenInclusionWithSubpath) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("a.$**" << 1) << "name" << "indexName" @@ -694,7 +669,6 @@ TEST(IndexSpecWildcard, FailsWhenInclusionWithSubpath) { } TEST(IndexSpecWildcard, FailsWhenExclusionWithSubpath) { - EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("a.$**" << 1) << "name" << "indexName" diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp index a1a3ab6d3af..3ebf1ce4935 100644 --- a/src/mongo/db/catalog/multi_index_block.cpp +++ b/src/mongo/db/catalog/multi_index_block.cpp @@ -72,19 +72,11 @@ namespace { * step down. A deadlock could result if the index build was attempting to acquire a Collection S * or X lock while a prepared transaction held a Collection IX lock, and a step down was waiting to * acquire the RSTL in mode X. - * We should only drop the RSTL while in FCV 4.2, as prepared transactions can only - * occur in FCV 4.2. */ void _unlockRSTLForIndexCleanup(OperationContext* opCtx) { if (!serverGlobalParams.featureCompatibility.isVersionInitialized()) { return; } - - if (serverGlobalParams.featureCompatibility.getVersion() != - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { - return; - } - opCtx->lockState()->unlockRSTLforPrepare(); invariant(!opCtx->lockState()->isRSTLLocked()); } diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index ec1d65deb3b..0a7482078b4 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -69,9 +69,9 @@ void FeatureCompatibilityVersion::setTargetUpgrade(OperationContext* opCtx) { // Sets both 'version' and 'targetVersion' fields. _runUpdateCommand(opCtx, [](auto updateMods) { updateMods.append(FeatureCompatibilityVersionParser::kVersionField, - FeatureCompatibilityVersionParser::kVersion40); - updateMods.append(FeatureCompatibilityVersionParser::kTargetVersionField, FeatureCompatibilityVersionParser::kVersion42); + updateMods.append(FeatureCompatibilityVersionParser::kTargetVersionField, + FeatureCompatibilityVersionParser::kVersion44); }); } @@ -79,9 +79,9 @@ void FeatureCompatibilityVersion::setTargetDowngrade(OperationContext* opCtx) { // Sets both 'version' and 'targetVersion' fields. _runUpdateCommand(opCtx, [](auto updateMods) { updateMods.append(FeatureCompatibilityVersionParser::kVersionField, - FeatureCompatibilityVersionParser::kVersion40); + FeatureCompatibilityVersionParser::kVersion42); updateMods.append(FeatureCompatibilityVersionParser::kTargetVersionField, - FeatureCompatibilityVersionParser::kVersion40); + FeatureCompatibilityVersionParser::kVersion42); }); } @@ -124,8 +124,8 @@ void FeatureCompatibilityVersion::setIfCleanStartup(OperationContext* opCtx, repl::TimestampedBSONObj{ BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << FeatureCompatibilityVersionParser::kVersionField - << (storeUpgradeVersion ? FeatureCompatibilityVersionParser::kVersion42 - : FeatureCompatibilityVersionParser::kVersion40)), + << (storeUpgradeVersion ? FeatureCompatibilityVersionParser::kVersion44 + : FeatureCompatibilityVersionParser::kVersion42)), Timestamp()}, repl::OpTime::kUninitializedTerm)); // No timestamp or term because this write is not // replicated. @@ -165,7 +165,7 @@ void FeatureCompatibilityVersion::onInsertOrUpdate(OperationContext* opCtx, cons serverGlobalParams.featureCompatibility.setVersion(newVersion); updateMinWireVersion(); - if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40) { + if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42) { // Close all incoming connections from internal clients with binary versions lower than // ours. opCtx->getServiceContext()->getServiceEntryPoint()->endAllSessions( @@ -176,7 +176,7 @@ void FeatureCompatibilityVersion::onInsertOrUpdate(OperationContext* opCtx, cons .dropConnections(transport::Session::kKeepOpen); } - if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { + if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { if (MONGO_FAIL_POINT(hangBeforeAbortingRunningTransactionsOnFCVDowngrade)) { log() << "featureCompatibilityVersion - " "hangBeforeAbortingRunningTransactionsOnFCVDowngrade fail point enabled. " @@ -196,17 +196,17 @@ void FeatureCompatibilityVersion::updateMinWireVersion() { WireSpec& spec = WireSpec::instance(); switch (serverGlobalParams.featureCompatibility.getVersion()) { - case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42: - case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42: - case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo40: + case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44: + case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44: + case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo42: spec.incomingInternalClient.minWireVersion = LATEST_WIRE_VERSION; spec.outgoing.minWireVersion = LATEST_WIRE_VERSION; return; - case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40: + case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42: spec.incomingInternalClient.minWireVersion = LATEST_WIRE_VERSION - 1; spec.outgoing.minWireVersion = LATEST_WIRE_VERSION - 1; return; - case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault40Behavior: + case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault42Behavior: // getVersion() does not return this value. MONGO_UNREACHABLE; } @@ -215,11 +215,11 @@ void FeatureCompatibilityVersion::updateMinWireVersion() { void FeatureCompatibilityVersion::_validateVersion(StringData version) { uassert(40284, str::stream() << "featureCompatibilityVersion must be '" - << FeatureCompatibilityVersionParser::kVersion42 << "' or '" - << FeatureCompatibilityVersionParser::kVersion40 << "'. See " + << FeatureCompatibilityVersionParser::kVersion44 << "' or '" + << FeatureCompatibilityVersionParser::kVersion42 << "'. See " << feature_compatibility_version_documentation::kCompatibilityLink << ".", - version == FeatureCompatibilityVersionParser::kVersion42 || - version == FeatureCompatibilityVersionParser::kVersion40); + version == FeatureCompatibilityVersionParser::kVersion44 || + version == FeatureCompatibilityVersionParser::kVersion42); } void FeatureCompatibilityVersion::_runUpdateCommand(OperationContext* opCtx, @@ -275,33 +275,33 @@ void FeatureCompatibilityVersionParameter::append(OperationContext* opCtx, BSONObjBuilder featureCompatibilityVersionBuilder(b.subobjStart(name)); switch (serverGlobalParams.featureCompatibility.getVersion()) { - case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42: + case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44: featureCompatibilityVersionBuilder.append( FeatureCompatibilityVersionParser::kVersionField, - FeatureCompatibilityVersionParser::kVersion42); + FeatureCompatibilityVersionParser::kVersion44); return; - case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42: + case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44: featureCompatibilityVersionBuilder.append( FeatureCompatibilityVersionParser::kVersionField, - FeatureCompatibilityVersionParser::kVersion40); + FeatureCompatibilityVersionParser::kVersion42); featureCompatibilityVersionBuilder.append( FeatureCompatibilityVersionParser::kTargetVersionField, - FeatureCompatibilityVersionParser::kVersion42); + FeatureCompatibilityVersionParser::kVersion44); return; - case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo40: + case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo42: featureCompatibilityVersionBuilder.append( FeatureCompatibilityVersionParser::kVersionField, - FeatureCompatibilityVersionParser::kVersion40); + FeatureCompatibilityVersionParser::kVersion42); featureCompatibilityVersionBuilder.append( FeatureCompatibilityVersionParser::kTargetVersionField, - FeatureCompatibilityVersionParser::kVersion40); + FeatureCompatibilityVersionParser::kVersion42); return; - case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40: + case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42: featureCompatibilityVersionBuilder.append( FeatureCompatibilityVersionParser::kVersionField, - FeatureCompatibilityVersionParser::kVersion40); + FeatureCompatibilityVersionParser::kVersion42); return; - case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault40Behavior: + case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault42Behavior: // getVersion() does not return this value. MONGO_UNREACHABLE; } diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h index c6f7a7f97d8..1c650fa1f0d 100644 --- a/src/mongo/db/commands/feature_compatibility_version.h +++ b/src/mongo/db/commands/feature_compatibility_version.h @@ -52,24 +52,23 @@ public: static Lock::ResourceMutex fcvLock; /** - * Records intent to perform a 4.0 -> 4.2 upgrade by updating the on-disk feature - * compatibility version document to have 'version'=4.0, 'targetVersion'=4.2. + * Records intent to perform a 4.2 -> 4.4 upgrade by updating the on-disk feature + * compatibility version document to have 'version'=4.2, 'targetVersion'=4.4. * Should be called before schemas are modified. */ static void setTargetUpgrade(OperationContext* opCtx); /** - * Records intent to perform a 4.2 -> 4.0 downgrade by updating the on-disk feature - * compatibility version document to have 'version'=4.0, 'targetVersion'=4.0. + * Records intent to perform a 4.4 -> 4.2 downgrade by updating the on-disk feature + * compatibility version document to have 'version'=4.2, 'targetVersion'=4.2. * Should be called before schemas are modified. */ static void setTargetDowngrade(OperationContext* opCtx); /** - * Records the completion of a 4.0 <-> 4.2 upgrade or downgrade by updating the on-disk feature + * Records the completion of a 4.2 <-> 4.4 upgrade or downgrade by updating the on-disk feature * compatibility version document to have 'version'=version and unsetting the 'targetVersion' - * field. - * Should be called after schemas are modified. + * field. Should be called after schemas are modified. */ static void unsetTargetUpgradeOrDowngrade(OperationContext* opCtx, StringData version); diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp index 919a2aae34c..1450e35ece6 100644 --- a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp +++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp @@ -77,12 +77,12 @@ StatusWith FeatureCompatibilityVersionCommandParser::extractVersion const std::string version = versionElem.String(); - if (version != FeatureCompatibilityVersionParser::kVersion42 && - version != FeatureCompatibilityVersionParser::kVersion40) { + if (version != FeatureCompatibilityVersionParser::kVersion44 && + version != FeatureCompatibilityVersionParser::kVersion42) { return {ErrorCodes::BadValue, str::stream() << "Invalid command argument. Expected '" - << FeatureCompatibilityVersionParser::kVersion42 << "' or '" - << FeatureCompatibilityVersionParser::kVersion40 << "', found " + << FeatureCompatibilityVersionParser::kVersion44 << "' or '" + << FeatureCompatibilityVersionParser::kVersion42 << "', found " << version << " in: " << cmdObj << ". See " << feature_compatibility_version_documentation::kCompatibilityLink << "."}; diff --git a/src/mongo/db/commands/feature_compatibility_version_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_parser.cpp index 0aa872b9041..d542d23c7a3 100644 --- a/src/mongo/db/commands/feature_compatibility_version_parser.cpp +++ b/src/mongo/db/commands/feature_compatibility_version_parser.cpp @@ -38,10 +38,10 @@ namespace mongo { -constexpr StringData FeatureCompatibilityVersionParser::kVersion40; constexpr StringData FeatureCompatibilityVersionParser::kVersion42; -constexpr StringData FeatureCompatibilityVersionParser::kVersionDowngradingTo40; -constexpr StringData FeatureCompatibilityVersionParser::kVersionUpgradingTo42; +constexpr StringData FeatureCompatibilityVersionParser::kVersion44; +constexpr StringData FeatureCompatibilityVersionParser::kVersionDowngradingTo42; +constexpr StringData FeatureCompatibilityVersionParser::kVersionUpgradingTo44; constexpr StringData FeatureCompatibilityVersionParser::kVersionUnset; constexpr StringData FeatureCompatibilityVersionParser::kParameterName; @@ -51,7 +51,7 @@ constexpr StringData FeatureCompatibilityVersionParser::kTargetVersionField; StatusWith FeatureCompatibilityVersionParser::parse(const BSONObj& featureCompatibilityVersionDoc) { ServerGlobalParams::FeatureCompatibility::Version version = - ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault40Behavior; + ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault42Behavior; std::string versionString; std::string targetVersionString; @@ -72,12 +72,12 @@ FeatureCompatibilityVersionParser::parse(const BSONObj& featureCompatibilityVers << "."); } - if (elem.String() != kVersion42 && elem.String() != kVersion40) { + if (elem.String() != kVersion44 && elem.String() != kVersion42) { return Status(ErrorCodes::BadValue, str::stream() << "Invalid value for " << fieldName << ", found " - << elem.String() << ", expected '" << kVersion42 << "' or '" - << kVersion40 << "'. Contents of " << kParameterName + << elem.String() << ", expected '" << kVersion44 << "' or '" + << kVersion42 << "'. Contents of " << kParameterName << " document in " << NamespaceString::kServerConfigurationNamespace.toString() << ": " << featureCompatibilityVersionDoc << ". See " @@ -102,16 +102,16 @@ FeatureCompatibilityVersionParser::parse(const BSONObj& featureCompatibilityVers } } - if (versionString == kVersion40) { - if (targetVersionString == kVersion42) { - version = ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42; - } else if (targetVersionString == kVersion40) { - version = ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo40; + if (versionString == kVersion42) { + if (targetVersionString == kVersion44) { + version = ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44; + } else if (targetVersionString == kVersion42) { + version = ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo42; } else { - version = ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40; + version = ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42; } - } else if (versionString == kVersion42) { - if (targetVersionString == kVersion42 || targetVersionString == kVersion40) { + } else if (versionString == kVersion44) { + if (targetVersionString == kVersion44 || targetVersionString == kVersion42) { return Status(ErrorCodes::BadValue, str::stream() << "Invalid state for " << kParameterName << " document in " @@ -120,7 +120,7 @@ FeatureCompatibilityVersionParser::parse(const BSONObj& featureCompatibilityVers << feature_compatibility_version_documentation::kCompatibilityLink << "."); } else { - version = ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42; + version = ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44; } } else { return Status(ErrorCodes::BadValue, diff --git a/src/mongo/db/commands/feature_compatibility_version_parser.h b/src/mongo/db/commands/feature_compatibility_version_parser.h index f563e09af2c..757d725a0bf 100644 --- a/src/mongo/db/commands/feature_compatibility_version_parser.h +++ b/src/mongo/db/commands/feature_compatibility_version_parser.h @@ -40,10 +40,10 @@ namespace mongo { */ class FeatureCompatibilityVersionParser { public: - static constexpr StringData kVersion40 = "4.0"_sd; static constexpr StringData kVersion42 = "4.2"_sd; - static constexpr StringData kVersionDowngradingTo40 = "downgrading to 4.0"_sd; - static constexpr StringData kVersionUpgradingTo42 = "upgrading to 4.2"_sd; + static constexpr StringData kVersion44 = "4.4"_sd; + static constexpr StringData kVersionDowngradingTo42 = "downgrading to 4.2"_sd; + static constexpr StringData kVersionUpgradingTo44 = "upgrading to 4.4"_sd; static constexpr StringData kVersionUnset = "Unset"_sd; static constexpr StringData kParameterName = "featureCompatibilityVersion"_sd; @@ -63,16 +63,16 @@ public: */ static StringData toString(ServerGlobalParams::FeatureCompatibility::Version version) { switch (version) { - case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault40Behavior: + case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault42Behavior: return kVersionUnset; - case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40: - return kVersion40; - case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42: - return kVersionUpgradingTo42; - case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo40: - return kVersionDowngradingTo40; - case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42: + case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42: return kVersion42; + case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44: + return kVersionUpgradingTo44; + case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo42: + return kVersionDowngradingTo42; + case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44: + return kVersion44; default: MONGO_UNREACHABLE; } 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 0238f1bf004..cfe59311ab4 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -62,7 +62,7 @@ MONGO_FAIL_POINT_DEFINE(featureCompatibilityDowngrade); MONGO_FAIL_POINT_DEFINE(featureCompatibilityUpgrade); /** - * Sets the minimum allowed version for the cluster. If it is 4.0, then the node should not use 4.2 + * Sets the minimum allowed version for the cluster. If it is 4.2, then the node should not use 4.4 * features. * * Format: @@ -88,13 +88,13 @@ public: } std::string help() const override { + using FCVP = FeatureCompatibilityVersionParser; std::stringstream h; - h << "Set the API version exposed by this node. If set to \"" - << FeatureCompatibilityVersionParser::kVersion40 - << "\", then 4.2 features are disabled. If \"" - << FeatureCompatibilityVersionParser::kVersion42 - << "\", then 4.2 features are enabled, and all nodes in the cluster must be binary " - "version 4.2. See " + h << "Set the API version exposed by this node. If set to '" << FCVP::kVersion42 + << "', then " << FCVP::kVersion44 << " features are disabled. If set to '" + << FCVP::kVersion44 << "', then " << FCVP::kVersion44 + << " features are enabled, and all nodes in the cluster must be binary version " + << FCVP::kVersion44 << ". See " << feature_compatibility_version_documentation::kCompatibilityLink << "."; return h.str(); } @@ -143,16 +143,16 @@ public: ServerGlobalParams::FeatureCompatibility::Version actualVersion = serverGlobalParams.featureCompatibility.getVersion(); - if (requestedVersion == FeatureCompatibilityVersionParser::kVersion42) { + if (requestedVersion == FeatureCompatibilityVersionParser::kVersion44) { uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion upgrade to 4.2 while a previous " - "featureCompatibilityVersion downgrade to 4.0 has not completed. Finish " - "downgrade to 4.0, then upgrade to 4.2.", + "cannot initiate featureCompatibilityVersion upgrade to 4.4 while a previous " + "featureCompatibilityVersion downgrade to 4.2 has not completed. Finish " + "downgrade to 4.2, then upgrade to 4.4.", actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo40); + ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo42); if (actualVersion == - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { // Set the client's last opTime to the system last opTime so no-ops wait for // writeConcern. repl::ReplClientInfo::forClient(opCtx->getClient()) @@ -166,7 +166,7 @@ public: // Take the global lock in S mode to create a barrier for operations taking the // global IX or X locks. This ensures that either // - The global IX/X locked operation will start after the FCV change, see the - // upgrading to 4.2 FCV and act accordingly. + // upgrading to 4.4 FCV and act accordingly. // - The global IX/X locked operation began prior to the FCV change, is acting on // that assumption and will finish before upgrade procedures begin right after // this. @@ -186,15 +186,15 @@ public: } FeatureCompatibilityVersion::unsetTargetUpgradeOrDowngrade(opCtx, requestedVersion); - } else if (requestedVersion == FeatureCompatibilityVersionParser::kVersion40) { + } else if (requestedVersion == FeatureCompatibilityVersionParser::kVersion42) { uassert(ErrorCodes::IllegalOperation, - "cannot initiate setting featureCompatibilityVersion to 4.0 while a previous " - "featureCompatibilityVersion upgrade to 4.2 has not completed.", + "cannot initiate setting featureCompatibilityVersion to 4.2 while a previous " + "featureCompatibilityVersion upgrade to 4.4 has not completed.", actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42); + ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44); if (actualVersion == - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40) { + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42) { // Set the client's last opTime to the system last opTime so no-ops wait for // writeConcern. repl::ReplClientInfo::forClient(opCtx->getClient()) @@ -208,7 +208,7 @@ public: // Take the global lock in S mode to create a barrier for operations taking the // global IX or X locks. This ensures that either // - The global IX/X locked operation will start after the FCV change, see the - // downgrading to 4.0 FCV and act accordingly. + // downgrading to 4.2 FCV and act accordingly. // - The global IX/X locked operation began prior to the FCV change, is acting on // that assumption and will finish before downgrade procedures begin right after // this. diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index dfe963eb877..50db2b33c2b 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -780,13 +780,8 @@ void IndexBuildsCoordinator::_runIndexBuildInner(OperationContext* opCtx, // deadlock could result if the index build was attempting to acquire a Collection S or // X lock while a prepared transaction held a Collection IX lock, and a step down was // waiting to acquire the RSTL in mode X. - // We should only drop the RSTL while in FCV 4.2, as prepared transactions can only - // occur in FCV 4.2. - if (serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { - const bool unlocked = opCtx->lockState()->unlockRSTLforPrepare(); - invariant(unlocked); - } + const bool unlocked = opCtx->lockState()->unlockRSTLforPrepare(); + invariant(unlocked); opCtx->runWithoutInterruptionExceptAtGlobalShutdown( [&, this] { _buildIndex(opCtx, collection, *nss, replState, &collLock); }); } else { diff --git a/src/mongo/db/repair_database_and_check_version.cpp b/src/mongo/db/repair_database_and_check_version.cpp index 01c965cb9d3..4f4d7d47fc3 100644 --- a/src/mongo/db/repair_database_and_check_version.cpp +++ b/src/mongo/db/repair_database_and_check_version.cpp @@ -74,8 +74,8 @@ MONGO_FAIL_POINT_DEFINE(exitBeforeRepairInvalidatesConfig); namespace { const std::string mustDowngradeErrorMsg = str::stream() - << "UPGRADE PROBLEM: The data files need to be fully upgraded to version 4.0 before attempting " - "an upgrade to 4.2; see " + << "UPGRADE PROBLEM: The data files need to be fully upgraded to version 4.2 before attempting " + "an upgrade to 4.4; see " << feature_compatibility_version_documentation::kUpgradeLink << " for more details."; Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx, @@ -111,11 +111,11 @@ Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx BSON("_id" << FeatureCompatibilityVersionParser::kParameterName), featureCompatibilityVersion)) { log() << "Re-creating featureCompatibilityVersion document that was deleted with version " - << FeatureCompatibilityVersionParser::kVersion40 << "."; + << FeatureCompatibilityVersionParser::kVersion42 << "."; BSONObj fcvObj = BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << FeatureCompatibilityVersionParser::kVersionField - << FeatureCompatibilityVersionParser::kVersion40); + << FeatureCompatibilityVersionParser::kVersion42); writeConflictRetry(opCtx, "insertFCVDocument", fcvNss.ns(), [&] { WriteUnitOfWork wunit(opCtx); @@ -504,7 +504,7 @@ bool repairDatabasesAndCheckVersion(OperationContext* opCtx) { auto swVersion = FeatureCompatibilityVersionParser::parse(featureCompatibilityVersion); // Note this error path captures all cases of an FCV document existing, - // but with any value other than "4.0" or "4.2". This includes unexpected + // but with any value other than "4.2" or "4.4". This includes unexpected // cases with no path forward such as the FCV value not being a string. uassert(ErrorCodes::MustDowngrade, str::stream() @@ -512,7 +512,7 @@ bool repairDatabasesAndCheckVersion(OperationContext* opCtx) { "featureCompatibilityVersion document (ERROR: " << swVersion.getStatus() << "). If the current featureCompatibilityVersion is below " - "4.0, see the documentation on upgrading at " + "4.2, see the documentation on upgrading at " << feature_compatibility_version_documentation::kUpgradeLink << ".", swVersion.isOK()); @@ -524,24 +524,24 @@ bool repairDatabasesAndCheckVersion(OperationContext* opCtx) { // On startup, if the version is in an upgrading or downrading state, print a // warning. if (version == - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42) { + ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44) { log() << "** WARNING: A featureCompatibilityVersion upgrade did not " << "complete. " << startupWarningsLog; log() << "** The current featureCompatibilityVersion is " << FeatureCompatibilityVersionParser::toString(version) << "." << startupWarningsLog; log() << "** To fix this, use the setFeatureCompatibilityVersion " - << "command to resume upgrade to 4.2." << startupWarningsLog; + << "command to resume upgrade to 4.4." << startupWarningsLog; } else if (version == ServerGlobalParams::FeatureCompatibility::Version:: - kDowngradingTo40) { + kDowngradingTo42) { log() << "** WARNING: A featureCompatibilityVersion downgrade did not " << "complete. " << startupWarningsLog; log() << "** The current featureCompatibilityVersion is " << FeatureCompatibilityVersionParser::toString(version) << "." << startupWarningsLog; log() << "** To fix this, use the setFeatureCompatibilityVersion " - << "command to resume downgrade to 4.0." << startupWarningsLog; + << "command to resume downgrade to 4.2." << startupWarningsLog; } } } diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index a0c250ff58c..8dc2170b6c4 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -852,8 +852,8 @@ void InitialSyncer::_fcvFetcherCallback(const StatusWith auto version = fCVParseSW.getValue(); // Changing the featureCompatibilityVersion during initial sync is unsafe. - if (version > ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40 && - version < ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { + if (version > ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42 && + version < ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { onCompletionGuard->setResultAndCancelRemainingWork_inlock( lock, Status(ErrorCodes::IncompatibleServerVersion, diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp index 47d4283b03b..b9eb16070bc 100644 --- a/src/mongo/db/repl/initial_syncer_test.cpp +++ b/src/mongo/db/repl/initial_syncer_test.cpp @@ -206,10 +206,10 @@ public: /** * Schedules and processes a successful response to the network request sent by InitialSyncer's - * feature compatibility version fetcher. Always includes a valid fCV=4.0 document in the - * response. + * feature compatibility version fetcher. Always includes a valid fCV=last-stable document in + * the response. */ - void processSuccessfulFCVFetcherResponse40(); + void processSuccessfulFCVFetcherResponseLastStable(); void finishProcessingNetworkResponse() { getNet()->runReadyNetworkOperations(); @@ -591,9 +591,9 @@ void assertFCVRequest(RemoteCommandRequest request) { request.cmdObj.getObjectField("filter")); } -void InitialSyncerTest::processSuccessfulFCVFetcherResponse40() { +void InitialSyncerTest::processSuccessfulFCVFetcherResponseLastStable() { auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "version" - << FeatureCompatibilityVersionParser::kVersion40)}; + << FeatureCompatibilityVersionParser::kVersion42)}; processSuccessfulFCVFetcherResponse(docs); } @@ -1459,7 +1459,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); } initialSyncer->join(); @@ -1608,7 +1608,7 @@ TEST_F(InitialSyncerTest, InitialSyncerResendsFindCommandIfFCVFetcherReturnsRetr ASSERT_TRUE(initialSyncer->isActive()); // FCV second attempt. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); } void InitialSyncerTest::runInitialSyncWithBadFCVResponse(std::vector docs, @@ -1651,7 +1651,7 @@ TEST_F(InitialSyncerTest, TEST_F(InitialSyncerTest, InitialSyncerReturnsTooManyMatchingDocumentsWhenFCVFetcherReturnsMultipleDocuments) { auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "version" - << FeatureCompatibilityVersionParser::kVersion40), + << FeatureCompatibilityVersionParser::kVersion42), BSON("_id" << "other")}; runInitialSyncWithBadFCVResponse(docs, ErrorCodes::TooManyMatchingDocuments); @@ -1660,22 +1660,22 @@ TEST_F(InitialSyncerTest, TEST_F(InitialSyncerTest, InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsUpgradeTargetVersion) { auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "version" - << FeatureCompatibilityVersionParser::kVersion40 << "targetVersion" - << FeatureCompatibilityVersionParser::kVersion42)}; + << FeatureCompatibilityVersionParser::kVersion42 << "targetVersion" + << FeatureCompatibilityVersionParser::kVersion44)}; runInitialSyncWithBadFCVResponse(docs, ErrorCodes::IncompatibleServerVersion); } TEST_F(InitialSyncerTest, InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsDowngradeTargetVersion) { auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "version" - << FeatureCompatibilityVersionParser::kVersion40 << "targetVersion" - << FeatureCompatibilityVersionParser::kVersion40)}; + << FeatureCompatibilityVersionParser::kVersion42 << "targetVersion" + << FeatureCompatibilityVersionParser::kVersion42)}; runInitialSyncWithBadFCVResponse(docs, ErrorCodes::IncompatibleServerVersion); } TEST_F(InitialSyncerTest, InitialSyncerReturnsBadValueWhenFCVFetcherReturnsNoVersion) { auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "targetVersion" - << FeatureCompatibilityVersionParser::kVersion40)}; + << FeatureCompatibilityVersionParser::kVersion42)}; runInitialSyncWithBadFCVResponse(docs, ErrorCodes::BadValue); } @@ -1704,7 +1704,7 @@ TEST_F(InitialSyncerTest, InitialSyncerSucceedsWhenFCVFetcherReturnsOldVersion) processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "version" - << FeatureCompatibilityVersionParser::kVersion40)}; + << FeatureCompatibilityVersionParser::kVersion42)}; processSuccessfulFCVFetcherResponse(docs); ASSERT_TRUE(net->hasReadyRequests()); } @@ -1757,7 +1757,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughOplogFetcherScheduleError) { net->runReadyNetworkOperations(); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // OplogFetcher will shut down DatabasesCloner on error after setting the completion status. // We call runReadyNetworkOperations() again to deliver the cancellation status to @@ -1801,7 +1801,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughOplogFetcherCallbackError) { net->runReadyNetworkOperations(); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); assertRemoteCommandNameEquals( "listDatabases", net->scheduleSuccessfulResponse(makeListDatabasesResponse({}))); @@ -1860,7 +1860,7 @@ TEST_F(InitialSyncerTest, net->runReadyNetworkOperations(); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); assertRemoteCommandNameEquals( "listDatabases", net->scheduleSuccessfulResponse(makeListDatabasesResponse({}))); @@ -1923,7 +1923,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); assertRemoteCommandNameEquals( "listDatabases", net->scheduleSuccessfulResponse(makeListDatabasesResponse({}))); @@ -1984,7 +1984,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); assertRemoteCommandNameEquals( "listDatabases", net->scheduleSuccessfulResponse(makeListDatabasesResponse({}))); @@ -2050,7 +2050,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // InitialSyncer shuts down OplogFetcher when it fails to schedule DatabasesCloner // so we should not expect any network requests in the queue. @@ -2096,7 +2096,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // DatabasesCloner's first remote command - listDatabases assertRemoteCommandNameEquals( @@ -2139,7 +2139,7 @@ TEST_F(InitialSyncerTest, InitialSyncerIgnoresLocalDatabasesWhenCloningDatabases processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // DatabasesCloner's first remote command - listDatabases assertRemoteCommandNameEquals( @@ -2208,7 +2208,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // DatabasesCloner's first remote command - listDatabases assertRemoteCommandNameEquals( @@ -2282,7 +2282,7 @@ TEST_F(InitialSyncerTest, InitialSyncerCancelsBothOplogFetcherAndDatabasesCloner processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); } ASSERT_OK(initialSyncer->shutdown()); @@ -2338,7 +2338,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2383,7 +2383,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2444,7 +2444,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2500,7 +2500,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2567,7 +2567,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2625,7 +2625,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(2)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2697,7 +2697,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2772,7 +2772,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2847,7 +2847,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2904,7 +2904,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -2966,7 +2966,7 @@ TEST_F(InitialSyncerTest, InitialSyncerCancelsLastRollbackCheckerOnShutdown) { processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3029,7 +3029,7 @@ TEST_F(InitialSyncerTest, InitialSyncerCancelsLastRollbackCheckerOnOplogFetcherC processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3097,7 +3097,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({oplogEntry}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3161,7 +3161,7 @@ TEST_F(InitialSyncerTest, LastOpTimeShouldBeSetEvenIfNoOperationsAreAppliedAfter processSuccessfulLastOplogEntryFetcherResponse({oplogEntry.toBSON()}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Instead of fast forwarding to DatabasesCloner completion by returning an empty list of // database names, we'll simulate copying a single database with a single collection on the @@ -3254,7 +3254,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughGetNextApplierBatchScheduleE processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3317,7 +3317,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughSecondGetNextApplierBatchSch processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3380,7 +3380,7 @@ TEST_F(InitialSyncerTest, InitialSyncerCancelsGetNextApplierBatchOnShutdown) { processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3445,7 +3445,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughGetNextApplierBatchInLockErr processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3518,7 +3518,7 @@ TEST_F( processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3582,7 +3582,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughMultiApplierScheduleError) { processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3662,7 +3662,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughMultiApplierCallbackError) { processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3717,7 +3717,7 @@ TEST_F(InitialSyncerTest, InitialSyncerCancelsGetNextApplierBatchCallbackOnOplog processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3778,7 +3778,7 @@ OplogEntry InitialSyncerTest::doInitialSyncWithOneBatch() { processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Quickest path to a successful DatabasesCloner completion is to respond to the // listDatabases with an empty list of database names. @@ -3875,7 +3875,7 @@ TEST_F(InitialSyncerTest, processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Instead of fast forwarding to DatabasesCloner completion by returning an empty list of // database names, we'll simulate copying a single database with a single collection on the @@ -3991,7 +3991,7 @@ TEST_F(InitialSyncerTest, OplogOutOfOrderOnOplogFetchFinish) { processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // Ignore listDatabases request. auto noi = net->getNextReadyRequest(); @@ -4064,7 +4064,7 @@ TEST_F(InitialSyncerTest, GetInitialSyncProgressReturnsCorrectProgress) { processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); } log() << "Done playing first failed response"; @@ -4119,7 +4119,7 @@ TEST_F(InitialSyncerTest, GetInitialSyncProgressReturnsCorrectProgress) { processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); } log() << "Done playing first successful response"; @@ -4334,7 +4334,7 @@ TEST_F(InitialSyncerTest, GetInitialSyncProgressOmitsClonerStatsIfClonerStatsExc processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(1)}); // Feature Compatibility Version. - processSuccessfulFCVFetcherResponse40(); + processSuccessfulFCVFetcherResponseLastStable(); // listDatabases NamespaceString nss("a.a"); diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 183f2527e19..fd60a8de505 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -2960,7 +2960,7 @@ ReplicationCoordinatorImpl::_updateMemberStateFromTopologyCoordinator(WithLock l // receive the replicated version. This is to avoid bugs like SERVER-32639. if (newState.arbiter()) { serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44); } _memberState = newState; diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp index f13cbeaa21c..dac500778f2 100644 --- a/src/mongo/db/repl/replication_recovery.cpp +++ b/src/mongo/db/repl/replication_recovery.cpp @@ -324,10 +324,10 @@ void ReplicationRecoveryImpl::_recoverFromUnstableCheckpoint(OperationContext* o // // Not waiting for checkpoint durability here can result in a scenario where the node takes // writes and persists them to the oplog, but crashes before a stable checkpoint persists a - // "recovery timestamp". The typical startup path for data-bearing nodes with 4.0 is to use - // the recovery timestamp to determine where to play oplog forward from. As this method shows, - // when a recovery timestamp does not exist, the applied through is used to determine where to - // start playing oplog entries from. + // "recovery timestamp". The typical startup path for data-bearing nodes is to use the recovery + // timestamp to determine where to play oplog forward from. As this method shows, when a + // recovery timestamp does not exist, the applied through is used to determine where to start + // playing oplog entries from. opCtx->recoveryUnit()->waitUntilUnjournaledWritesDurable(); } diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp index 84d31b48a9a..ab77100a66e 100644 --- a/src/mongo/db/repl/replication_recovery_test.cpp +++ b/src/mongo/db/repl/replication_recovery_test.cpp @@ -818,8 +818,7 @@ TEST_F(ReplicationRecoveryTest, RecoveryDoesNotApplyOperationsIfAppliedThroughIs _assertDocsInOplog(opCtx, {5}); _assertDocsInTestCollection(opCtx, {}); ASSERT(getConsistencyMarkers()->getOplogTruncateAfterPoint(opCtx).isNull()); - // In 4.0 with RTT, recovering without a `recoverTimestamp` will set `appliedThrough` to the - // top of oplog. + // Recovering without a `recoverTimestamp` will set `appliedThrough` to the top of oplog. ASSERT_EQ(OpTime(Timestamp(5, 5), 1), getConsistencyMarkers()->getAppliedThrough(opCtx)); } diff --git a/src/mongo/db/repl/sync_tail_test_fixture.cpp b/src/mongo/db/repl/sync_tail_test_fixture.cpp index 42036edba5d..b3b4835c860 100644 --- a/src/mongo/db/repl/sync_tail_test_fixture.cpp +++ b/src/mongo/db/repl/sync_tail_test_fixture.cpp @@ -133,7 +133,7 @@ void SyncTailTest::setUp() { // test fixture does not create a featureCompatibilityVersion document from which to initialize // the server parameter. serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44); } void SyncTailTest::tearDown() { diff --git a/src/mongo/db/repl_index_build_state.h b/src/mongo/db/repl_index_build_state.h index 363eba6eb94..94d88ce78c4 100644 --- a/src/mongo/db/repl_index_build_state.h +++ b/src/mongo/db/repl_index_build_state.h @@ -48,15 +48,13 @@ namespace mongo { // Indicates which protocol an index build is using. enum class IndexBuildProtocol { /** - * Refers to the pre-FCV 4.2 index build protocol for building indexes in replica sets. - * Index builds must complete on the primary before replicating, and are not resumable in - * any scenario. + * Refers to the legacy index build protocol for building indexes in replica sets. Index builds + * must complete on the primary before replicating, and are not resumable in any scenario. */ kSinglePhase, /** - * Refers to the FCV 4.2 two-phase index build protocol for building indexes in replica - * sets. Indexes are built simultaneously on all nodes and are resumable during the draining - * phase. + * Refers to the two-phase index build protocol for building indexes in replica sets. Indexes + * are built simultaneously on all nodes and are resumable during the draining phase. */ kTwoPhase }; 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 6d9282dde0a..337f854354e 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 @@ -138,7 +138,6 @@ protected: }); } - // TODO: SERVER-42654 void expectSetFeatureCompatibilityVersion(const HostAndPort& target, StatusWith response, BSONObj writeConcern) { @@ -147,7 +146,7 @@ protected: ASSERT_EQ(request.dbname, "admin"); ASSERT_BSONOBJ_EQ(request.cmdObj, BSON("setFeatureCompatibilityVersion" - << "4.2" + << "4.4" << "writeConcern" << writeConcern)); return response; 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 225c7a25c1e..14781634e42 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 @@ -337,16 +337,15 @@ StatusWith ShardingCatalogManager::_validateHostAsShard( << "field when attempting to add " << connectionString.toString() << " as a shard"); } - // TODO: SERVER-42592 if (serverGlobalParams.featureCompatibility.getVersion() > - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40) { - // If the cluster's FCV is 4.2, or upgrading to / downgrading from, the node being added - // must be a v4.2 binary. + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42) { + // If the cluster's FCV is 4.4, or upgrading to / downgrading from, the node being added + // must be a v4.4 binary. invariant(maxWireVersion == WireVersion::LATEST_WIRE_VERSION); } else { - // If the cluster's FCV is 4.0, the node being added must be a v4.0 or v4.2 binary. + // If the cluster's FCV is 4.2, the node being added must be a v4.2 or v4.4 binary. invariant(serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40); + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42); invariant(maxWireVersion >= WireVersion::LATEST_WIRE_VERSION - 1); } @@ -647,27 +646,9 @@ StatusWith ShardingCatalogManager::addShard( AddShard addShardCmd = add_shard_util::createAddShardCmd(opCtx, shardType.getName()); - // TODO: SERVER-42592 - auto addShardCmdBSON = [&]() { - // In 4.2, use the _addShard command to add the shard, which in turn inserts a - // shardIdentity document into the shard and triggers sharding state initialization. - // In the unlikely scenario that there's a downgrade to 4.0 between the - // construction of this command object and the issuing of the command - // on the receiving shard, the user will receive a rather harmless - // CommandNotFound error for _addShard, and can simply retry. - if (serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { - // Needed for IDL toBSON method - BSONObj passthroughFields; - return addShardCmd.toBSON(passthroughFields); - } else { - // To support backwards compatibility with v4.0 shards, insert a shardIdentity document - // directly. - return add_shard_util::createShardIdentityUpsertForAddShard(addShardCmd); - } - }(); - - auto addShardStatus = runCmdOnNewShard(addShardCmdBSON); + // Use the _addShard command to add the shard, which in turn inserts a shardIdentity document + // into the shard and triggers sharding state initialization. + auto addShardStatus = runCmdOnNewShard(addShardCmd.toBSON({})); if (!addShardStatus.isOK()) { return addShardStatus; @@ -682,19 +663,18 @@ StatusWith ShardingCatalogManager::addShard( invariant(!opCtx->lockState()->isLocked()); Lock::SharedLock lk(opCtx->lockState(), FeatureCompatibilityVersion::fcvLock); - // TODO: SERVER-42592 BSONObj setFCVCmd; switch (serverGlobalParams.featureCompatibility.getVersion()) { - case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42: - case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42: + case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44: + case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44: setFCVCmd = BSON(FeatureCompatibilityVersionCommandParser::kCommandName - << FeatureCompatibilityVersionParser::kVersion42 + << FeatureCompatibilityVersionParser::kVersion44 << WriteConcernOptions::kWriteConcernField << opCtx->getWriteConcern().toBSON()); break; default: setFCVCmd = BSON(FeatureCompatibilityVersionCommandParser::kCommandName - << FeatureCompatibilityVersionParser::kVersion40 + << FeatureCompatibilityVersionParser::kVersion42 << WriteConcernOptions::kWriteConcernField << opCtx->getWriteConcern().toBSON()); break; diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index 73f49e8e150..3e82a903af8 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -165,40 +165,40 @@ struct ServerGlobalParams { * * The legal enum (and featureCompatibilityVersion document) states are: * - * kFullyDowngradedTo40 - * (4.0, Unset): Only 4.0 features are available, and new and existing storage - * engine entries use the 4.0 format + * kFullyDowngradedTo42 + * (4.2, Unset): Only 4.2 features are available, and new and existing storage + * engine entries use the 4.2 format * - * kUpgradingTo42 - * (4.0, 4.2): Only 4.0 features are available, but new storage engine entries - * use the 4.2 format, and existing entries may have either the - * 4.0 or 4.2 format + * kUpgradingTo44 + * (4.2, 4.4): Only 4.2 features are available, but new storage engine entries + * use the 4.4 format, and existing entries may have either the + * 4.2 or 4.4 format * - * kFullyUpgradedTo42 - * (4.2, Unset): 4.2 features are available, and new and existing storage - * engine entries use the 4.2 format + * kFullyUpgradedTo44 + * (4.4, Unset): 4.4 features are available, and new and existing storage + * engine entries use the 4.4 format * - * kDowngradingTo40 - * (4.0, 4.0): Only 4.0 features are available and new storage engine - * entries use the 4.0 format, but existing entries may have - * either the 4.0 or 4.2 format + * kDowngradingTo42 + * (4.2, 4.2): Only 4.2 features are available and new storage engine + * entries use the 4.2 format, but existing entries may have + * either the 4.2 or 4.4 format * - * kUnsetDefault40Behavior + * kUnsetDefault42Behavior * (Unset, Unset): This is the case on startup before the fCV document is * loaded into memory. isVersionInitialized() will return * false, and getVersion() will return the default - * (kFullyDowngradedTo40). + * (kFullyDowngradedTo42). * */ enum class Version { // The order of these enums matter, higher upgrades having higher values, so that // features can be active or inactive if the version is higher than some minimum or // lower than some maximum, respectively. - kUnsetDefault40Behavior = 0, - kFullyDowngradedTo40 = 1, - kDowngradingTo40 = 2, - kUpgradingTo42 = 3, - kFullyUpgradedTo42 = 4, + kUnsetDefault42Behavior = 0, + kFullyDowngradedTo42 = 1, + kDowngradingTo42 = 2, + kUpgradingTo44 = 3, + kFullyUpgradedTo44 = 4, }; /** @@ -206,7 +206,7 @@ struct ServerGlobalParams { * exposes the actual state of the featureCompatibilityVersion if it is uninitialized. */ const bool isVersionInitialized() const { - return _version.load() != Version::kUnsetDefault40Behavior; + return _version.load() != Version::kUnsetDefault42Behavior; } /** @@ -226,11 +226,11 @@ struct ServerGlobalParams { */ const Version getVersionUnsafe() const { Version v = _version.load(); - return (v == Version::kUnsetDefault40Behavior) ? Version::kFullyDowngradedTo40 : v; + return (v == Version::kUnsetDefault42Behavior) ? Version::kFullyDowngradedTo42 : v; } void reset() { - _version.store(Version::kUnsetDefault40Behavior); + _version.store(Version::kUnsetDefault42Behavior); } void setVersion(Version version) { @@ -238,12 +238,12 @@ struct ServerGlobalParams { } bool isVersionUpgradingOrUpgraded() { - return (getVersion() == Version::kUpgradingTo42 || - getVersion() == Version::kFullyUpgradedTo42); + return (getVersion() == Version::kUpgradingTo44 || + getVersion() == Version::kFullyUpgradedTo44); } private: - AtomicWord _version{Version::kUnsetDefault40Behavior}; + AtomicWord _version{Version::kUnsetDefault42Behavior}; } featureCompatibility; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 8abc8da8390..d49cdfe821b 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -118,13 +118,14 @@ bool WiredTigerFileVersion::shouldDowngrade(bool readOnly, if (!serverGlobalParams.featureCompatibility.isVersionInitialized()) { // If the FCV document hasn't been read, trust the WT compatibility. MongoD will // downgrade to the same compatibility it discovered on startup. - return _startupVersion == StartupVersion::IS_40 || - _startupVersion == StartupVersion::IS_36 || _startupVersion == StartupVersion::IS_34; + return _startupVersion == StartupVersion::IS_42 || + _startupVersion == StartupVersion::IS_40 || _startupVersion == StartupVersion::IS_36 || + _startupVersion == StartupVersion::IS_34; } if (serverGlobalParams.featureCompatibility.getVersion() != - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo40) { - // Only consider downgrading when FCV is set to 4.0 + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42) { + // Only consider downgrading when FCV is set to 4.2 return false; } @@ -148,7 +149,7 @@ bool WiredTigerFileVersion::shouldDowngrade(bool readOnly, std::string WiredTigerFileVersion::getDowngradeString() { if (!serverGlobalParams.featureCompatibility.isVersionInitialized()) { - invariant(_startupVersion != StartupVersion::IS_42); + invariant(_startupVersion != StartupVersion::IS_44); switch (_startupVersion) { case StartupVersion::IS_34: @@ -157,11 +158,13 @@ std::string WiredTigerFileVersion::getDowngradeString() { return "compatibility=(release=3.0)"; case StartupVersion::IS_40: return "compatibility=(release=3.1)"; + case StartupVersion::IS_42: + return "compatibility=(release=3.2)"; default: MONGO_UNREACHABLE; } } - return "compatibility=(release=3.1)"; + return "compatibility=(release=3.2)"; } using std::set; @@ -745,7 +748,7 @@ void WiredTigerKVEngine::_openWiredTiger(const std::string& path, const std::str int ret = wiredtiger_open(path.c_str(), wtEventHandler, configStr.c_str(), &_conn); if (!ret) { - _fileVersion = {WiredTigerFileVersion::StartupVersion::IS_40}; + _fileVersion = {WiredTigerFileVersion::StartupVersion::IS_42}; return; } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 67d1ef8ba14..bb8c1e4c76c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -56,7 +56,7 @@ class WiredTigerSessionCache; class WiredTigerSizeStorer; struct WiredTigerFileVersion { - enum class StartupVersion { IS_34, IS_36, IS_40, IS_42 }; + enum class StartupVersion { IS_34, IS_36, IS_40, IS_42, IS_44 }; StartupVersion _startupVersion; bool shouldDowngrade(bool readOnly, bool repairMode, bool hasRecoveryTimestamp); diff --git a/src/mongo/db/views/view_catalog.cpp b/src/mongo/db/views/view_catalog.cpp index 6019a012b1a..a2de077d063 100644 --- a/src/mongo/db/views/view_catalog.cpp +++ b/src/mongo/db/views/view_catalog.cpp @@ -325,11 +325,11 @@ StatusWith> ViewCatalog::_validatePipeline( // Save this to a variable to avoid reading the atomic variable multiple times. auto currentFCV = serverGlobalParams.featureCompatibility.getVersion(); - // If the feature compatibility version is not 4.2, and we are validating features as master, - // ban the use of new agg features introduced in 4.2 to prevent them from being persisted in the + // If the feature compatibility version is not 4.4, and we are validating features as master, + // ban the use of new agg features introduced in 4.4 to prevent them from being persisted in the // catalog. if (serverGlobalParams.validateFeaturesAsMaster.load() && - currentFCV != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) { + currentFCV != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { expCtx->maxFeatureCompatibilityVersion = currentFCV; } auto pipelineStatus = Pipeline::parse(viewDef.pipeline(), std::move(expCtx)); diff --git a/src/mongo/db/wire_version.h b/src/mongo/db/wire_version.h index 8ecb08fd7dd..561070f2a1c 100644 --- a/src/mongo/db/wire_version.h +++ b/src/mongo/db/wire_version.h @@ -76,9 +76,12 @@ enum WireVersion { // Supports sharded transactions (4.2+). SHARDED_TRANSACTIONS = 8, + // TODO SERVER-42985: Supports some upcoming feature (4.4+). + PLACEHOLDER_FOR_44 = 9, + // Set this to the highest value in this enum - it will be the default maxWireVersion for // the WireSpec values. - LATEST_WIRE_VERSION = SHARDED_TRANSACTIONS, + LATEST_WIRE_VERSION = PLACEHOLDER_FOR_44, }; /** diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp index 942678a87dd..62238c52cf7 100644 --- a/src/mongo/dbtests/dbtests.cpp +++ b/src/mongo/dbtests/dbtests.cpp @@ -182,7 +182,7 @@ int dbtestsMain(int argc, char** argv, char** envp) { mongo::runGlobalInitializersOrDie(argc, argv, envp); serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44); repl::ReplSettings replSettings; replSettings.setOplogSizeBytes(10 * 1024 * 1024); setGlobalServiceContext(ServiceContext::make()); 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 570551c7352..aff4f4214d8 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 @@ -70,14 +70,14 @@ public: } std::string help() const override { + using FCVP = FeatureCompatibilityVersionParser; return str::stream() - << "Set the API version for the cluster. If set to \"" - << FeatureCompatibilityVersionParser::kVersion40 - << "\", then 4.2 features are disabled. If \"" - << FeatureCompatibilityVersionParser::kVersion42 - << "\", then 4.2 features are enabled, and all nodes in the cluster must be version " - << "4.2. See " << feature_compatibility_version_documentation::kCompatibilityLink - << "."; + << "Set the API version used by this cluster. If set to '" << FCVP::kVersion42 + << "', then " << FCVP::kVersion44 << " features are disabled. If set to '" + << FCVP::kVersion44 << "', then " << FCVP::kVersion44 + << " features are enabled, and all nodes in the cluster must be binary version " + << FCVP::kVersion44 << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink << "."; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index c94bb38f2e9..92282a63a73 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -679,10 +679,11 @@ MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default")) // to the latest version because there is no feature gating that currently occurs at the mongos // level. The shards are responsible for rejecting usages of new features if their // featureCompatibilityVersion is lower. -MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion42, ("EndStartupOptionStorage")) +MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersionLatest, + ("EndStartupOptionStorage")) (InitializerContext* context) { serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44); return Status::OK(); } diff --git a/src/mongo/s/sharding_mongod_test_fixture.cpp b/src/mongo/s/sharding_mongod_test_fixture.cpp index 2a427e29b09..7d7b8419e58 100644 --- a/src/mongo/s/sharding_mongod_test_fixture.cpp +++ b/src/mongo/s/sharding_mongod_test_fixture.cpp @@ -144,11 +144,10 @@ void ShardingMongodTestFixture::setUp() { repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); - // TODO: SERVER-42592 // 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. serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44); } std::unique_ptr ShardingMongodTestFixture::makeReplicationCoordinator( diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp index 12911840cb9..bb39c1d4060 100644 --- a/src/mongo/shell/dbshell.cpp +++ b/src/mongo/shell/dbshell.cpp @@ -99,10 +99,11 @@ const std::string kDefaultMongoURL = "mongodb://"s + kDefaultMongoHost + ":"s + // to the latest version because there is no feature gating that currently occurs at the mongo shell // level. The server is responsible for rejecting usages of new features if its // featureCompatibilityVersion is lower. -MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion42, ("EndStartupOptionSetup")) +MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersionLatest, + ("EndStartupOptionSetup")) (InitializerContext* context) { mongo::serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44); return Status::OK(); } diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js index 8ada418abea..d31bab4ebee 100644 --- a/src/mongo/shell/shardingtest.js +++ b/src/mongo/shell/shardingtest.js @@ -1467,7 +1467,7 @@ var ShardingTest = function(params) { const configRS = this.configRS; if (_hasNewFeatureCompatibilityVersion() && _isMixedVersionCluster()) { function setFeatureCompatibilityVersion() { - assert.commandWorked(csrsPrimary.adminCommand({setFeatureCompatibilityVersion: '4.0'})); + assert.commandWorked(csrsPrimary.adminCommand({setFeatureCompatibilityVersion: '4.2'})); // Wait for the new featureCompatibilityVersion to propagate to all nodes in the CSRS // to ensure that older versions of mongos can successfully connect. diff --git a/src/mongo/unittest/unittest.cpp b/src/mongo/unittest/unittest.cpp index 3cce9bf868d..1aee738eb4a 100644 --- a/src/mongo/unittest/unittest.cpp +++ b/src/mongo/unittest/unittest.cpp @@ -169,7 +169,7 @@ UnsafeScopeGuard MakeUnsafeScopeGuard(F fun) { // with a meaningful value will trigger failures as of SERVER-32630. void setUpFCV() { serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44); } void tearDownFCV() { serverGlobalParams.featureCompatibility.reset(); -- cgit v1.2.1