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 --- .../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 ++++++++-------- 6 files changed, 85 insertions(+), 86 deletions(-) (limited to 'src/mongo/db/commands') 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. -- cgit v1.2.1