diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-02-20 17:26:45 -0500 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-02-23 16:56:20 -0500 |
commit | de6ceb82f5b554f16517295adfd39c8bfd407926 (patch) | |
tree | 398687bf08c09379e46d38e2f00f17b2352b2fb4 /src | |
parent | fd83ef4e9069e4dee7149b3dc589be66590a520f (diff) | |
download | mongo-de6ceb82f5b554f16517295adfd39c8bfd407926.tar.gz |
SERVER-33179 Remove featureCompatibilityVersion 3.4
Diffstat (limited to 'src')
18 files changed, 105 insertions, 421 deletions
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp index fad8950aed0..7a8ccfdb0b1 100644 --- a/src/mongo/db/catalog/catalog_control.cpp +++ b/src/mongo/db/catalog/catalog_control.cpp @@ -152,13 +152,11 @@ void openCatalog(OperationContext* opCtx) { << collName); auto uuid = collection->uuid(); - // TODO (SERVER-32597): When the minimum featureCompatibilityVersion becomes 3.6, we - // can change this condition to be an invariant. - if (uuid) { - LOG(1) << "openCatalog: registering uuid " << uuid->toString() << " for collection " - << collName; - uuidCatalog.registerUUIDCatalogEntry(*uuid, collection); - } + invariant(uuid); + + LOG(1) << "openCatalog: registering uuid " << uuid->toString() << " for collection " + << collName; + uuidCatalog.registerUUIDCatalogEntry(*uuid, collection); // If this is the oplog collection, re-establish the replication system's cached pointer // to the oplog. diff --git a/src/mongo/db/commands/apply_ops_cmd.cpp b/src/mongo/db/commands/apply_ops_cmd.cpp index e7dc2a5a6fa..34010f2aa3f 100644 --- a/src/mongo/db/commands/apply_ops_cmd.cpp +++ b/src/mongo/db/commands/apply_ops_cmd.cpp @@ -163,13 +163,6 @@ OplogApplicationValidity validateApplyOpsCommand(const BSONObj& cmdObj) { bool opHasUUIDs = operationContainsUUID(opObj); - if (serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34) { - uassert(ErrorCodes::OplogOperationUnsupported, - "applyOps with UUID requires upgrading to FeatureCompatibilityVersion 3.6", - !opHasUUIDs); - } - // If the op uses any UUIDs at all then the user must possess extra privileges. if (opHasUUIDs && ret == OplogApplicationValidity::kOk) ret = OplogApplicationValidity::kNeedsUseUUID; diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index 1781a956435..afa789dd60e 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -89,17 +89,14 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili } if (elem.String() != FeatureCompatibilityVersionCommandParser::kVersion40 && - elem.String() != FeatureCompatibilityVersionCommandParser::kVersion36 && - elem.String() != FeatureCompatibilityVersionCommandParser::kVersion34) { + elem.String() != FeatureCompatibilityVersionCommandParser::kVersion36) { return Status(ErrorCodes::BadValue, str::stream() << "Invalid value for " << fieldName << ", found " << elem.String() << ", expected '" << FeatureCompatibilityVersionCommandParser::kVersion40 - << "', '" - << FeatureCompatibilityVersionCommandParser::kVersion36 << "' or '" - << FeatureCompatibilityVersionCommandParser::kVersion34 + << FeatureCompatibilityVersionCommandParser::kVersion36 << "'. Contents of " << FeatureCompatibilityVersion::kParameterName << " document in " @@ -130,48 +127,17 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili } } - if (versionString == FeatureCompatibilityVersionCommandParser::kVersion34) { - if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion40) { - return Status(ErrorCodes::BadValue, - str::stream() << "Invalid state for " - << FeatureCompatibilityVersion::kParameterName - << " document in " - << FeatureCompatibilityVersion::kCollection - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version::kDochubLink - << "."); - } else if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion36) { - version = ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36; - } else if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion34) { - version = ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo34; - } else { - version = ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34; - } - } else if (versionString == FeatureCompatibilityVersionCommandParser::kVersion36) { + if (versionString == FeatureCompatibilityVersionCommandParser::kVersion36) { if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion40) { version = ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo40; } else if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion36) { version = ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo36; - } else if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion34) { - return Status(ErrorCodes::BadValue, - str::stream() << "Invalid state for " - << FeatureCompatibilityVersion::kParameterName - << " document in " - << FeatureCompatibilityVersion::kCollection - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version::kDochubLink - << "."); } else { version = ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36; } } else if (versionString == FeatureCompatibilityVersionCommandParser::kVersion40) { if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion40 || - targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion36 || - targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion34) { + targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion36) { return Status(ErrorCodes::BadValue, str::stream() << "Invalid state for " << FeatureCompatibilityVersion::kParameterName @@ -203,26 +169,6 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili return version; } -void FeatureCompatibilityVersion::setTargetUpgrade_DEPRECATED(OperationContext* opCtx) { - // Sets both 'version' and 'targetVersion' fields. - _runUpdateCommand(opCtx, [](auto updateMods) { - updateMods.append(FeatureCompatibilityVersion::kVersionField, - FeatureCompatibilityVersionCommandParser::kVersion34); - updateMods.append(FeatureCompatibilityVersion::kTargetVersionField, - FeatureCompatibilityVersionCommandParser::kVersion36); - }); -} - -void FeatureCompatibilityVersion::setTargetDowngrade_DEPRECATED(OperationContext* opCtx) { - // Sets both 'version' and 'targetVersion' fields. - _runUpdateCommand(opCtx, [](auto updateMods) { - updateMods.append(FeatureCompatibilityVersion::kVersionField, - FeatureCompatibilityVersionCommandParser::kVersion34); - updateMods.append(FeatureCompatibilityVersion::kTargetVersionField, - FeatureCompatibilityVersionCommandParser::kVersion34); - }); -} - void FeatureCompatibilityVersion::setTargetUpgrade(OperationContext* opCtx) { // Sets both 'version' and 'targetVersion' fields. _runUpdateCommand(opCtx, [](auto updateMods) { @@ -346,15 +292,9 @@ void FeatureCompatibilityVersion::updateMinWireVersion() { spec.outgoing.minWireVersion = LATEST_WIRE_VERSION; return; case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36: - case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36: - case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo34: spec.incomingInternalClient.minWireVersion = LATEST_WIRE_VERSION - 1; spec.outgoing.minWireVersion = LATEST_WIRE_VERSION - 1; return; - case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34: - spec.incomingInternalClient.minWireVersion = LATEST_WIRE_VERSION - 2; - spec.outgoing.minWireVersion = LATEST_WIRE_VERSION - 2; - return; case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault36Behavior: // getVersion() does not return this value. MONGO_UNREACHABLE; @@ -365,16 +305,13 @@ void FeatureCompatibilityVersion::_validateVersion(StringData version) { uassert(40284, str::stream() << "featureCompatibilityVersion must be '" << FeatureCompatibilityVersionCommandParser::kVersion40 - << "', '" - << FeatureCompatibilityVersionCommandParser::kVersion36 << "' or '" - << FeatureCompatibilityVersionCommandParser::kVersion34 + << FeatureCompatibilityVersionCommandParser::kVersion36 << "'. See " << feature_compatibility_version::kDochubLink << ".", version == FeatureCompatibilityVersionCommandParser::kVersion40 || - version == FeatureCompatibilityVersionCommandParser::kVersion36 || - version == FeatureCompatibilityVersionCommandParser::kVersion34); + version == FeatureCompatibilityVersionCommandParser::kVersion36); } void FeatureCompatibilityVersion::_runUpdateCommand(OperationContext* opCtx, @@ -449,27 +386,6 @@ public: FeatureCompatibilityVersion::kVersionField, FeatureCompatibilityVersionCommandParser::kVersion36); return; - case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36: - featureCompatibilityVersionBuilder.append( - FeatureCompatibilityVersion::kVersionField, - FeatureCompatibilityVersionCommandParser::kVersion34); - featureCompatibilityVersionBuilder.append( - FeatureCompatibilityVersion::kTargetVersionField, - FeatureCompatibilityVersionCommandParser::kVersion36); - return; - case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo34: - featureCompatibilityVersionBuilder.append( - FeatureCompatibilityVersion::kVersionField, - FeatureCompatibilityVersionCommandParser::kVersion34); - featureCompatibilityVersionBuilder.append( - FeatureCompatibilityVersion::kTargetVersionField, - FeatureCompatibilityVersionCommandParser::kVersion34); - return; - case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34: - featureCompatibilityVersionBuilder.append( - FeatureCompatibilityVersion::kVersionField, - FeatureCompatibilityVersionCommandParser::kVersion34); - return; case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault36Behavior: // 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 1c3916565b0..02f8e3df7f6 100644 --- a/src/mongo/db/commands/feature_compatibility_version.h +++ b/src/mongo/db/commands/feature_compatibility_version.h @@ -75,12 +75,6 @@ public: switch (version) { case ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault36Behavior: return FeatureCompatibilityVersionCommandParser::kVersionUnset; - case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34: - return FeatureCompatibilityVersionCommandParser::kVersion34; - case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36: - return FeatureCompatibilityVersionCommandParser::kVersionUpgradingTo36; - case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo34: - return FeatureCompatibilityVersionCommandParser::kVersionDowngradingTo34; case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36: return FeatureCompatibilityVersionCommandParser::kVersion36; case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo40: @@ -95,20 +89,6 @@ public: } /** - * Records intent to perform a 3.4 -> 3.6 upgrade by updating the on-disk feature - * compatibility version document to have 'version'=3.4, 'targetVersion'=3.6. - * Should be called before schemas are modified. - */ - static void setTargetUpgrade_DEPRECATED(OperationContext* opCtx); - - /** - * Records intent to perform a 3.6 -> 3.4 downgrade by updating the on-disk feature - * compatibility version document to have 'version'=3.4, 'targetVersion'=3.4. - * Should be called before schemas are modified. - */ - static void setTargetDowngrade_DEPRECATED(OperationContext* opCtx); - - /** * Records intent to perform a 3.6 -> 4.0 upgrade by updating the on-disk feature * compatibility version document to have 'version'=3.6, 'targetVersion'=4.0. * Should be called before schemas are modified. @@ -123,9 +103,9 @@ public: static void setTargetDowngrade(OperationContext* opCtx); /** - * Records the completion of a 3.4 <-> 3.6 or 3.6 <-> 4.0 upgrade or downgrade by updating the - * on-disk feature compatibility version document to have 'version'=version and unsetting the - * 'targetVersion' field. + * Records the completion of a 3.6 <-> 4.0 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. */ 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 c8dd5dfcecc..49ce4128b8d 100644 --- a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp +++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp @@ -38,11 +38,8 @@ namespace mongo { -constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion34; constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion36; constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion40; -constexpr StringData FeatureCompatibilityVersionCommandParser::kVersionUpgradingTo36; -constexpr StringData FeatureCompatibilityVersionCommandParser::kVersionDowngradingTo34; constexpr StringData FeatureCompatibilityVersionCommandParser::kVersionUpgradingTo40; constexpr StringData FeatureCompatibilityVersionCommandParser::kVersionDowngradingTo36; constexpr StringData FeatureCompatibilityVersionCommandParser::kVersionUnset; @@ -88,15 +85,12 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion const std::string version = versionElem.String(); if (version != FeatureCompatibilityVersionCommandParser::kVersion40 && - version != FeatureCompatibilityVersionCommandParser::kVersion36 && - version != FeatureCompatibilityVersionCommandParser::kVersion34) { + version != FeatureCompatibilityVersionCommandParser::kVersion36) { return {ErrorCodes::BadValue, str::stream() << "Invalid command argument. Expected '" << FeatureCompatibilityVersionCommandParser::kVersion40 - << "', '" - << FeatureCompatibilityVersionCommandParser::kVersion36 << "' or '" - << FeatureCompatibilityVersionCommandParser::kVersion34 + << FeatureCompatibilityVersionCommandParser::kVersion36 << "', found " << version << " in: " diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.h b/src/mongo/db/commands/feature_compatibility_version_command_parser.h index 0f19576765e..284471de123 100644 --- a/src/mongo/db/commands/feature_compatibility_version_command_parser.h +++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.h @@ -47,11 +47,8 @@ public: /** * Known server release versions. */ - static constexpr StringData kVersion34 = "3.4"_sd; static constexpr StringData kVersion36 = "3.6"_sd; static constexpr StringData kVersion40 = "4.0"_sd; - static constexpr StringData kVersionUpgradingTo36 = "upgrading to 3.6"_sd; - static constexpr StringData kVersionDowngradingTo34 = "downgrading to 3.4"_sd; static constexpr StringData kVersionUpgradingTo40 = "upgrading to 4.0"_sd; static constexpr StringData kVersionDowngradingTo36 = "downgrading to 3.6"_sd; static constexpr StringData kVersionUnset = "Unset"_sd; diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 54b0d7efaef..a687ec89a29 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -423,8 +423,7 @@ void State::prepTempCollection() { CollectionOptions options; options.setNoIdIndex(); options.temp = true; - if (enableCollectionUUIDs && - serverGlobalParams.featureCompatibility.isSchemaVersion36()) { + if (enableCollectionUUIDs) { options.uuid.emplace(UUID::gen()); } incColl = incCtx.db()->createCollection(_opCtx, _config.incLong.ns(), options); @@ -510,7 +509,7 @@ void State::prepTempCollection() { CollectionOptions options = finalOptions; options.temp = true; - if (enableCollectionUUIDs && serverGlobalParams.featureCompatibility.isSchemaVersion36()) { + if (enableCollectionUUIDs) { // If a UUID for the final output collection was sent by mongos (i.e., the final output // collection is sharded), use the UUID mongos sent when creating the temp collection. // When the temp collection is renamed to the final output collection, the UUID will be @@ -1754,8 +1753,7 @@ public: Config config(dbname, cmdObj.firstElement().embeddedObjectUserCheck()); - if (cmdObj["finalOutputCollIsSharded"].trueValue() && - serverGlobalParams.featureCompatibility.isSchemaVersion36()) { + if (cmdObj["finalOutputCollIsSharded"].trueValue()) { uassert(ErrorCodes::InvalidOptions, "This shard has feature compatibility version 3.6, so it expects mongos to " "send the UUID to use for the sharded output collection. Was the mapReduce " 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 e9b510d4120..bccb159e9ef 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -84,11 +84,11 @@ public: std::string help() const override { std::stringstream h; h << "Set the API version exposed by this node. If set to \"" - << FeatureCompatibilityVersionCommandParser::kVersion34 - << "\", then 3.6 features are disabled. If \"" << FeatureCompatibilityVersionCommandParser::kVersion36 - << "\", then 3.6 features are enabled, and all nodes in the cluster must be version " - "3.6. See " + << "\", then 4.0 features are disabled. If \"" + << FeatureCompatibilityVersionCommandParser::kVersion40 + << "\", then 4.0 features are enabled, and all nodes in the cluster must be binary " + "version 4.0. See " << feature_compatibility_version::kDochubLink << "."; return h.str(); } @@ -139,22 +139,6 @@ public: if (requestedVersion == FeatureCompatibilityVersionCommandParser::kVersion40) { uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion upgrade to 4.0 when in 3.4. " - "Upgrade to featureCompatibility 3.6 before upgrading to 4.0.", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34); - uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion upgrade to 4.0 while a previous " - "downgrade to 3.4 has not completed. Finish downgrade to 3.4, upgrade to 3.6, " - "and then 4.0.", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo34); - uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion upgrade to 4.0 while a previous " - "upgrade to 3.6 has not completed. Finish upgrade to 3.6, then upgrade to 4.0.", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36); - uassert(ErrorCodes::IllegalOperation, "cannot initiate featureCompatibilityVersion upgrade to 4.0 while a previous " "featureCompatibilityVersion downgrade to 3.6 has not completed. Finish " "downgrade to 3.6, then upgrade to 4.0.", @@ -172,7 +156,18 @@ public: FeatureCompatibilityVersion::setTargetUpgrade(opCtx); - // If config server, upgrade shards *after* upgrading self. + { + // 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.0 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. + Lock::GlobalLock lk(opCtx, MODE_S, Date_t::max()); + } + + // Upgrade shards before config finishes its upgrade. if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { uassertStatusOK( ShardingCatalogManager::get(opCtx)->setFeatureCompatibilityVersionOnShards( @@ -188,11 +183,6 @@ public: } else if (requestedVersion == FeatureCompatibilityVersionCommandParser::kVersion36) { uassert(ErrorCodes::IllegalOperation, "cannot initiate setting featureCompatibilityVersion to 3.6 while a previous " - "featureCompatibilityVersion downgrade to 3.4 has not completed.", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo34); - uassert(ErrorCodes::IllegalOperation, - "cannot initiate setting featureCompatibilityVersion to 3.6 while a previous " "featureCompatibilityVersion upgrade to 4.0 has not completed.", actualVersion != ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo40); @@ -206,140 +196,20 @@ public: return true; } - if (actualVersion == - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo40 || - actualVersion == - ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo36) { - // Downgrading to 3.6. - - FeatureCompatibilityVersion::setTargetDowngrade(opCtx); - - // If config server, downgrade shards *before* downgrading self - if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { - uassertStatusOK( - ShardingCatalogManager::get(opCtx)->setFeatureCompatibilityVersionOnShards( - opCtx, - CommandHelpers::appendMajorityWriteConcern( - CommandHelpers::appendPassthroughFields( - cmdObj, - BSON(FeatureCompatibilityVersion::kCommandName - << requestedVersion))))); - } - - FeatureCompatibilityVersion::unsetTargetUpgradeOrDowngrade(opCtx, requestedVersion); - } else { - // Upgrading to 3.6. - - invariant( - actualVersion == - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34 || - actualVersion == - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36); - - FeatureCompatibilityVersion::setTargetUpgrade_DEPRECATED(opCtx); - - { - // Take the global lock in S mode to create a barrier for createCollection - // execution, which takes a database exclusive lock. This ensures that either - // - createCollection will start after the FCV change and see the upgrading to - // 3.6 FCV and create the collection with a UUID. - // - createCollection that began prior to the FCV change, and is creating a - // collection without UUID, will finish before the updateUUIDSchemaVersion - // call below fetches a list of collections to which to add UUIDs for any - // without a UUID. - // Otherwise createCollection may determine not to add a UUID before the FCV - // change, but then actually create the collection after the update below - // identifies all of the databases to update with UUIDs. - Lock::GlobalLock lk(opCtx, MODE_S, Date_t::max()); - } - - // First put UUIDs in the storage layer metadata. UUIDs will be generated for - // unsharded collections; shards will query the config server for sharded collection - // UUIDs. Remove after 3.4 -> 3.6 upgrade. - updateUUIDSchemaVersion(opCtx, /*upgrade*/ true); - - // If config server, upgrade shards *after* upgrading self. - if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { - // Remove after 3.4 -> 3.6 upgrade. - ShardingCatalogManager::get(opCtx)->generateUUIDsForExistingShardedCollections( - opCtx); - - uassertStatusOK( - ShardingCatalogManager::get(opCtx)->setFeatureCompatibilityVersionOnShards( - opCtx, - CommandHelpers::appendMajorityWriteConcern( - CommandHelpers::appendPassthroughFields( - cmdObj, - BSON(FeatureCompatibilityVersion::kCommandName - << requestedVersion))))); - } - - // Fail after adding UUIDs but before updating the FCV document. - if (MONGO_FAIL_POINT(featureCompatibilityUpgrade)) { - exitCleanly(EXIT_CLEAN); - } - - FeatureCompatibilityVersion::unsetTargetUpgradeOrDowngrade(opCtx, requestedVersion); - } - } else { - invariant(requestedVersion == FeatureCompatibilityVersionCommandParser::kVersion34); - - uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion downgrade to 3.4 when in 4.0. " - "Downgrade to featureCompatibility 3.6 before downgrading to 3.4", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo40); - uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion downgrade to 3.4 while a previous " - "upgrade to 4.0 has not completed. Finish upgrade to 4.0, downgrade to 3.6, " - "and then 3.4.", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo40); - uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion downgrade to 3.4 while a previous " - "downgrade to 3.6 has not completed. Finish downgrade to 3.6, then downgrade " - " to 3.4.", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo36); - uassert(ErrorCodes::IllegalOperation, - "cannot initiate featureCompatibilityVersion downgrade to 3.4 while a previous " - "featureCompatibilityVersion upgrade to 3.6 has not completed. Finish upgrade " - "to 3.6, then downgrade to 3.4.", - actualVersion != - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36); - - if (actualVersion == - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34) { - // Set the client's last opTime to the system last opTime so no-ops wait for - // writeConcern. - repl::ReplClientInfo::forClient(opCtx->getClient()) - .setLastOpToSystemLastOpTime(opCtx); - return true; - } - - FeatureCompatibilityVersion::setTargetDowngrade_DEPRECATED(opCtx); + FeatureCompatibilityVersion::setTargetDowngrade(opCtx); { - // Take the global lock in S mode to create a barrier for createCollection - // execution, which takea a database exclusive lock. This ensures that either - // - createCollection will start after the FCV change, see downgrading to 3.4 FCV - // and not create the collection with a UUID. - // - createCollection that began prior to the FCV change, and is creating a - // collection with UUID, will finish before the updateUUIDSchemaVersion call - // below fetches a list of collections from which to remove UUIDs for any with - // a UUID. - // Otherwise createCollection may determine to add a UUID before the FCV change, but - // then actually create the collection after the update below identifies all of the - // databases from which to remove UUIDs. + // 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 3.6 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. Lock::GlobalLock lk(opCtx, MODE_S, Date_t::max()); } - // Fail after updating the FCV document but before removing UUIDs. - if (MONGO_FAIL_POINT(featureCompatibilityDowngrade)) { - exitCleanly(EXIT_CLEAN); - } - - // If config server, downgrade shards *before* downgrading self. + // Downgrade shards before config finishes its downgrade. if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { uassertStatusOK( ShardingCatalogManager::get(opCtx)->setFeatureCompatibilityVersionOnShards( @@ -351,9 +221,6 @@ public: << requestedVersion))))); } - // Remove after 3.6 -> 3.4 downgrade. - updateUUIDSchemaVersion(opCtx, /*upgrade*/ false); - FeatureCompatibilityVersion::unsetTargetUpgradeOrDowngrade(opCtx, requestedVersion); } diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index eb7a3175ee9..b6fd8a4b9e2 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -207,18 +207,11 @@ public: bool skipUUIDCheck = nss.coll() == "system.indexes" || nss.coll() == "system.namespaces"; if (!skipUUIDCheck) { - ServerGlobalParams::FeatureCompatibility::Version version = - serverGlobalParams.featureCompatibility.getVersion(); - - if (version >= - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36) { - // All collections must have a UUID. - if (!opts.uuid) { - results.errors.push_back(str::stream() << "UUID missing on collection " - << nss.ns() - << " but SchemaVersion=3.6"); - results.valid = false; - } + // All collections must have a UUID. + if (!opts.uuid) { + results.errors.push_back(str::stream() << "UUID missing on collection " << nss.ns() + << " but SchemaVersion=3.6"); + results.valid = false; } } diff --git a/src/mongo/db/repair_database_and_check_version.cpp b/src/mongo/db/repair_database_and_check_version.cpp index bf847c31d1a..0b627043dce 100644 --- a/src/mongo/db/repair_database_and_check_version.cpp +++ b/src/mongo/db/repair_database_and_check_version.cpp @@ -395,25 +395,7 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { // On startup, if the version is in an upgrading or downrading state, print a // warning. if (version == - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo36) { - log() << "** WARNING: A featureCompatibilityVersion upgrade did not " - << "complete." << startupWarningsLog; - log() << "** The current featureCompatibilityVersion is " - << FeatureCompatibilityVersion::toString(version) << "." - << startupWarningsLog; - log() << "** To fix this, use the setFeatureCompatibilityVersion " - << "command to resume upgrade to 3.6." << startupWarningsLog; - } else if (version == ServerGlobalParams::FeatureCompatibility::Version:: - kDowngradingTo34) { - log() << "** WARNING: A featureCompatibilityVersion downgrade did not " - << "complete. " << startupWarningsLog; - log() << "** The current featureCompatibilityVersion is " - << FeatureCompatibilityVersion::toString(version) << "." - << startupWarningsLog; - log() << "** To fix this, use the setFeatureCompatibilityVersion " - << "command to resume downgrade to 3.4." << startupWarningsLog; - } else if (version == - ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo40) { + ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo40) { log() << "** WARNING: A featureCompatibilityVersion upgrade did not " << "complete. " << startupWarningsLog; log() << "** The current featureCompatibilityVersion is " diff --git a/src/mongo/db/repl/check_quorum_for_config_change.cpp b/src/mongo/db/repl/check_quorum_for_config_change.cpp index e1a2321d91e..52f7d3ce361 100644 --- a/src/mongo/db/repl/check_quorum_for_config_change.cpp +++ b/src/mongo/db/repl/check_quorum_for_config_change.cpp @@ -90,10 +90,7 @@ std::vector<RemoteCommandRequest> QuorumChecker::getRequests() const { hbArgs.setSetName(_rsConfig->getReplSetName()); hbArgs.setProtocolVersion(1); hbArgs.setConfigVersion(_rsConfig->getConfigVersion()); - if (serverGlobalParams.featureCompatibility.getVersion() != - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34) { - hbArgs.setHeartbeatVersion(1); - } + hbArgs.setHeartbeatVersion(1); hbArgs.setCheckEmpty(isInitialConfig); hbArgs.setSenderHost(myConfig.getHostAndPort()); hbArgs.setSenderId(myConfig.getId()); @@ -103,10 +100,7 @@ std::vector<RemoteCommandRequest> QuorumChecker::getRequests() const { ReplSetHeartbeatArgsV1 hbArgs; hbArgs.setSetName(_rsConfig->getReplSetName()); hbArgs.setConfigVersion(_rsConfig->getConfigVersion()); - if (serverGlobalParams.featureCompatibility.getVersion() != - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34) { - hbArgs.setHeartbeatVersion(1); - } + hbArgs.setHeartbeatVersion(1); if (isInitialConfig) { hbArgs.setCheckEmpty(); } diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp index e8b3710f283..686f7008dd3 100644 --- a/src/mongo/db/repl/topology_coordinator.cpp +++ b/src/mongo/db/repl/topology_coordinator.cpp @@ -940,10 +940,7 @@ std::pair<ReplSetHeartbeatArgs, Milliseconds> TopologyCoordinator::prepareHeartb hbArgs.setSetName(ourSetName); hbArgs.setConfigVersion(-2); } - if (serverGlobalParams.featureCompatibility.getVersion() != - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34) { - hbArgs.setHeartbeatVersion(1); - } + hbArgs.setHeartbeatVersion(1); const Milliseconds timeoutPeriod( _rsConfig.isInitialized() ? _rsConfig.getHeartbeatTimeoutPeriodMillis() @@ -979,10 +976,7 @@ std::pair<ReplSetHeartbeatArgsV1, Milliseconds> TopologyCoordinator::prepareHear hbArgs.setConfigVersion(-2); hbArgs.setTerm(OpTime::kInitialTerm); } - if (serverGlobalParams.featureCompatibility.getVersion() != - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34) { - hbArgs.setHeartbeatVersion(1); - } + hbArgs.setHeartbeatVersion(1); const Milliseconds timeoutPeriod( _rsConfig.isInitialized() ? _rsConfig.getHeartbeatTimeoutPeriodMillis() diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp index 1ad8459f3f1..4dc2b459384 100644 --- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp @@ -643,11 +643,6 @@ void migrateAndFurtherSplitInitialChunks(OperationContext* opCtx, boost::optional<UUID> getUUIDFromPrimaryShard(const NamespaceString& nss, ScopedDbConnection& conn) { - // UUIDs were introduced in featureCompatibilityVersion 3.6. - if (!serverGlobalParams.featureCompatibility.isSchemaVersion36()) { - return boost::none; - } - // Obtain the collection's UUID from the primary shard's listCollections response. BSONObj res; { 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 79489af4c9e..5d93e1d7a62 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 @@ -340,20 +340,14 @@ StatusWith<ShardType> ShardingCatalogManager::_validateHostAsShard( } if (serverGlobalParams.featureCompatibility.getVersion() > ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36) { - // If FCV 4.0, or upgrading to / downgrading from, wire version must be LATEST. + // If the cluster's FCV is 4.0, or upgrading to / downgrading from, the node being added + // must be a v4.0 binary. invariant(maxWireVersion == WireVersion::LATEST_WIRE_VERSION); - } else if (serverGlobalParams.featureCompatibility.getVersion() > - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34 && - serverGlobalParams.featureCompatibility.getVersion() <= - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36) { - // If FCV 3.6, or upgrading to / downgrading from, wire version must be v3.6 - // LATEST_WIRE_VERSION or greater. - invariant(maxWireVersion >= WireVersion::LATEST_WIRE_VERSION - 1); } else { - // If FCV 3.4, wire version cannot be less than v3.4 LATEST_WIRE_VERSION. + // If the cluster's FCV is 3.6, the node being added must be a v3.6 or v4.0 binary. invariant(serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34); - invariant(maxWireVersion >= WireVersion::LATEST_WIRE_VERSION - 2); + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36); + invariant(maxWireVersion >= WireVersion::LATEST_WIRE_VERSION - 1); } // Check whether there is a master. If there isn't, the replica set may not have been diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index a29bbc368bf..ac2746f180a 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -561,25 +561,21 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* opCtx, donorOptionsBob.appendElements(entry["options"].Obj()); } - if (serverGlobalParams.featureCompatibility.isSchemaVersion36()) { - BSONObj info; - if (entry["info"].isABSONObj()) { - info = entry["info"].Obj(); - } - if (info["uuid"].eoo()) { - setStateFailWarn(str::stream() - << "The donor shard did not return a UUID for collection " - << _nss.ns() - << " as part of its listCollections response: " - << entry - << ", but this node expects to see a UUID since its " - "feature compatibility version is 3.6. Please follow " - "the online documentation to set the same feature " - "compatibility version across the cluster."); - return; - } - donorOptionsBob.append(info["uuid"]); + BSONObj info; + if (entry["info"].isABSONObj()) { + info = entry["info"].Obj(); + } + if (info["uuid"].eoo()) { + setStateFailWarn(str::stream() + << "The donor shard did not return a UUID for collection " + << _nss.ns() + << " as part of its listCollections response: " + << entry + << ", but this node expects to see a UUID."); + return; } + donorOptionsBob.append(info["uuid"]); + donorOptions = donorOptionsBob.obj(); } diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index e0a34ddb39c..d5c2e141826 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -152,25 +152,25 @@ struct ServerGlobalParams { * Features can be gated for specific versions, or ranges of versions above or below some * minimum or maximum version, respectively. * - * The legal enum (and featureCompatiblityVersion document) states are: - * - * kFullyDowngradedTo34 - * (3.4, Unset): Only 3.4 features are available, and new and existing storage - * engine entries use the 3.4 format - * - * kUpgradingTo36 - * (3.4, 3.6): Only 3.4 features are available, but new storage engine entries - * use the 3.6 format, and existing entries may have either the - * 3.4 or 3.6 format + * The legal enum (and featureCompatibilityVersion document) states are: * * kFullyDowngradedTo36 - * (3.6, Unset): 3.6 features are available, and new and existing storage + * (3.6, Unset): Only 3.6 features are available, and new and existing storage * engine entries use the 3.6 format * - * kDowngradingTo34 - * (3.4, 3.4): Only 3.4 features are available and new storage engine - * entries use the 3.4 format, but existing entries may have - * either the 3.4 or 3.6 format + * kUpgradingTo40 + * (3.6, 4.0): Only 3.6 features are available, but new storage engine entries + * use the 4.0 format, and existing entries may have either the + * 3.6 or 4.0 format + * + * kFullyUpgradedTo40 + * (4.0, Unset): 4.0 features are available, and new and existing storage + * engine entries use the 4.0 format + * + * kDowngradingTo36 + * (3.6, 3.6): Only 3.6 features are available and new storage engine + * entries use the 3.6 format, but existing entries may have + * either the 3.6 or 4.0 format * * kUnsetDefault36Behavior * (Unset, Unset): This is the case on startup before the fCV document is @@ -178,20 +178,16 @@ struct ServerGlobalParams { * false, and getVersion() will return the default * (kFullyDowngradedTo36). * - * TODO: update this comment to 3.6/4.0 when FCV 3.4 is removed (SERVER-33179). */ 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. kUnsetDefault36Behavior = 0, - kFullyDowngradedTo34 = 1, - kDowngradingTo34 = 2, - kUpgradingTo36 = 3, - kFullyDowngradedTo36 = 4, - kDowngradingTo36 = 5, - kUpgradingTo40 = 6, - kFullyUpgradedTo40 = 7, + kFullyDowngradedTo36 = 1, + kDowngradingTo36 = 2, + kUpgradingTo40 = 3, + kFullyUpgradedTo40 = 4, }; /** @@ -219,10 +215,9 @@ struct ServerGlobalParams { return _version.store(version); } - // This determines whether to give Collections UUIDs upon creation. - const bool isSchemaVersion36() { - return (getVersion() >= Version::kFullyDowngradedTo36 || - getVersion() == Version::kUpgradingTo36); + const bool isVersionUpgradingOrUpgraded() { + return (getVersion() == Version::kUpgradingTo40 || + getVersion() == Version::kFullyUpgradedTo40); } private: diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index cbd613857a8..016ba8a7a61 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -510,21 +510,21 @@ void WiredTigerKVEngine::cleanShutdown() { // There are two cases to consider where the server will shutdown before the in-memory FCV // state is set. One is when `EncryptionHooks::restartRequired` is true. The other is when // the server shuts down because it refuses to acknowledge an FCV value more than one - // version behind (e.g: 3.6 errors when reading 3.2). + // version behind (e.g: 4.0 errors when reading 3.4). // // In the first case, we ideally do not perform a file format downgrade (but it is - // acceptable). In the second, the server must downgrade to allow a 3.4 binary to start + // acceptable). In the second, the server must downgrade to allow a 3.6 binary to start // up. Ideally, our internal FCV value would allow for older values, even if only to // immediately shutdown. This would allow downstream logic, such as this method, to make // an informed decision. const bool needsDowngrade = !_readOnly && serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34; + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36; invariantWTOK(_conn->close(_conn, closeConfig)); _conn = nullptr; - // If FCV 3.4, enable WT logging on all tables. + // If FCV 3.6, enable WT logging on all tables. if (needsDowngrade) { // Steps for downgrading: // @@ -534,8 +534,8 @@ void WiredTigerKVEngine::cleanShutdown() { // 2) Enable WiredTiger logging on all tables. // // 3) Reconfigure the WiredTiger to release compatibility 2.9. The WiredTiger version - // shipped with MongoDB 3.4 will always refuse to start up without this reconfigure - // being successful. Doing this last prevents MongoDB running in 3.4 with only some + // shipped with MongoDB 3.6 will always refuse to start up without this reconfigure + // being successful. Doing this last prevents MongoDB running in 3.6 with only some // underlying tables being logged. LOG(1) << "Downgrading WiredTiger tables to release compatibility 2.9"; WT_CONNECTION* conn; 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 ff753df8c69..21f2a9b259e 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 @@ -67,15 +67,13 @@ public: } std::string help() const override { - // TODO: update this comment when FCV 3.4 is removed (SERVER-33179). return str::stream() << "Set the API version for the cluster. If set to \"" - << FeatureCompatibilityVersionCommandParser::kVersion34 - << "\", then 3.6 features are disabled. If \"" << FeatureCompatibilityVersionCommandParser::kVersion36 - << "\", then 3.6 features are enabled, and all nodes in the cluster must be version " - << "3.6. If \"4.0\", then 4.0 features are enabled. See " - << feature_compatibility_version::kDochubLink << "."; + << "\", then 4.0 features are disabled. If \"" + << FeatureCompatibilityVersionCommandParser::kVersion40 + << "\", then 4.0 features are enabled, and all nodes in the cluster must be version " + << "4.0. See " << feature_compatibility_version::kDochubLink << "."; } Status checkAuthForCommand(Client* client, |