diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-03-05 09:31:16 -0500 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-03-16 12:02:15 -0400 |
commit | 906c8056bdab9ed6270e445927b24dd8ef2618aa (patch) | |
tree | 2e1f890adbf29d287342d3402c3e76209a63e336 /src/mongo/db | |
parent | fafb34dda41840937f062ab0a48fd784d63b8803 (diff) | |
download | mongo-906c8056bdab9ed6270e445927b24dd8ef2618aa.tar.gz |
SERVER-33562 Move FeatureCompatibilityVersion::kCollection/kDatabase into namespace_string.h
and clean up some file dependencies
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/commands/feature_compatibility_version.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/commands/feature_compatibility_version.h | 9 | ||||
-rw-r--r-- | src/mongo/db/commands/feature_compatibility_version_command_parser.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/feature_compatibility_version_parser.cpp | 117 | ||||
-rw-r--r-- | src/mongo/db/commands/feature_compatibility_version_parser.h | 5 | ||||
-rw-r--r-- | src/mongo/db/commands/rename_collection_cmd.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/namespace_string.h | 4 | ||||
-rw-r--r-- | src/mongo/db/op_observer_impl.cpp | 19 | ||||
-rw-r--r-- | src/mongo/db/repair_database_and_check_version.cpp | 28 | ||||
-rw-r--r-- | src/mongo/db/repl/SConscript | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/initial_syncer.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/repl/initial_syncer_test.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_tail_test.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/s/config/configsvr_shard_collection_command.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/server_options.h | 5 |
17 files changed, 123 insertions, 136 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript index 6d492b765a2..d6aeba17592 100644 --- a/src/mongo/db/commands/SConscript +++ b/src/mongo/db/commands/SConscript @@ -60,6 +60,7 @@ env.Library( ], LIBDEPS=[ '$BUILD_DIR/mongo/base', + '$BUILD_DIR/mongo/db/namespace_string', ], ) diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index e9b98c38c63..b617228c4b7 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -36,6 +36,7 @@ #include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/commands/feature_compatibility_version_parser.h" #include "mongo/db/dbdirectclient.h" +#include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/optime.h" #include "mongo/db/repl/storage_interface.h" @@ -53,9 +54,6 @@ namespace mongo { using repl::UnreplicatedWritesBlock; -constexpr StringData FeatureCompatibilityVersion::kCollection; -constexpr StringData FeatureCompatibilityVersion::kDatabase; - Lock::ResourceMutex FeatureCompatibilityVersion::fcvLock("featureCompatibilityVersionLock"); void FeatureCompatibilityVersion::setTargetUpgrade(OperationContext* opCtx) { @@ -101,7 +99,7 @@ void FeatureCompatibilityVersion::setIfCleanStartup(OperationContext* opCtx, const bool storeUpgradeVersion = serverGlobalParams.clusterRole != ClusterRole::ShardServer; UnreplicatedWritesBlock unreplicatedWritesBlock(opCtx); - NamespaceString nss(FeatureCompatibilityVersion::kCollection); + NamespaceString nss(NamespaceString::kServerConfigurationNamespace); { CollectionOptions options; @@ -109,7 +107,7 @@ void FeatureCompatibilityVersion::setIfCleanStartup(OperationContext* opCtx, uassertStatusOK(storageInterface->createCollection(opCtx, nss, options)); } - // We then insert the featureCompatibilityVersion document into the "admin.system.version" + // We then insert the featureCompatibilityVersion document into the server configuration // collection. The server parameter will be updated on commit by the op observer. uassertStatusOK(storageInterface->insertDocument( opCtx, @@ -210,7 +208,7 @@ void FeatureCompatibilityVersion::_validateVersion(StringData version) { void FeatureCompatibilityVersion::_runUpdateCommand(OperationContext* opCtx, UpdateBuilder builder) { DBDirectClient client(opCtx); - NamespaceString nss(FeatureCompatibilityVersion::kCollection); + NamespaceString nss(NamespaceString::kServerConfigurationNamespace); BSONObjBuilder updateCmd; updateCmd.append("update", nss.coll()); @@ -231,7 +229,7 @@ void FeatureCompatibilityVersion::_runUpdateCommand(OperationContext* opCtx, } updateCmd.append(WriteConcernOptions::kWriteConcernField, WriteConcernOptions::Majority); - // Update the featureCompatibilityVersion document stored in the "admin.system.version" + // Update the featureCompatibilityVersion document stored in the server configuration // collection. BSONObj updateResult; client.runCommand(nss.db().toString(), updateCmd.obj(), updateResult); diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h index 727ef8529fe..e41530edddd 100644 --- a/src/mongo/db/commands/feature_compatibility_version.h +++ b/src/mongo/db/commands/feature_compatibility_version.h @@ -47,9 +47,6 @@ extern bool internalValidateFeaturesAsMaster; class FeatureCompatibilityVersion { public: - static constexpr StringData kCollection = "admin.system.version"_sd; - static constexpr StringData kDatabase = "admin"_sd; - /** * Should be taken in shared mode by any operations that should not run while * setFeatureCompatibilityVersion is running. @@ -96,9 +93,9 @@ public: static bool isCleanStartUp(); /** - * Examines a document inserted or updated in admin.system.version. If it is the - * featureCompatibilityVersion document, validates the document and on commit, updates - * the server parameter. + * Examines a document inserted or updated in the server configuration collection + * (admin.system.version). If it is the featureCompatibilityVersion document, validates the + * document and on commit, updates the server parameter. */ static void onInsertOrUpdate(OperationContext* opCtx, const BSONObj& doc); 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 ddb479f75f0..f9a66bd6f34 100644 --- a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp +++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp @@ -35,8 +35,6 @@ #include "mongo/db/commands.h" #include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/commands/feature_compatibility_version_parser.h" -#include "mongo/db/query/query_request.h" -#include "mongo/util/version.h" namespace mongo { diff --git a/src/mongo/db/commands/feature_compatibility_version_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_parser.cpp index 8aea75ac1a9..30eeca1bf4c 100644 --- a/src/mongo/db/commands/feature_compatibility_version_parser.cpp +++ b/src/mongo/db/commands/feature_compatibility_version_parser.cpp @@ -33,6 +33,7 @@ #include "mongo/base/status.h" #include "mongo/bson/bsonobj.h" #include "mongo/db/commands/feature_compatibility_version_documentation.h" +#include "mongo/db/namespace_string.h" namespace mongo { @@ -61,42 +62,37 @@ FeatureCompatibilityVersionParser::parse(const BSONObj& featureCompatibilityVers if (elem.type() != BSONType::String) { return Status( ErrorCodes::TypeMismatch, - str::stream() - << fieldName - << " must be of type String, but was of type " - << typeName(elem.type()) - << ". Contents of " - << kParameterName - << " document in " - << "admin.system.version" // TODO: NamespaceString constant (SERVER-33562) - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version_documentation::kCompatibilityLink - << "."); + str::stream() << fieldName << " must be of type String, but was of type " + << typeName(elem.type()) + << ". Contents of " + << kParameterName + << " document in " + << NamespaceString::kServerConfigurationNamespace.toString() + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } if (elem.String() != kVersion40 && elem.String() != kVersion36) { return Status( ErrorCodes::BadValue, - str::stream() - << "Invalid value for " - << fieldName - << ", found " - << elem.String() - << ", expected '" - << kVersion40 - << "' or '" - << kVersion36 - << "'. Contents of " - << kParameterName - << " document in " - << "admin.system.version" // TODO: NamespaceString constant (SERVER-33562) - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version_documentation::kCompatibilityLink - << "."); + str::stream() << "Invalid value for " << fieldName << ", found " + << elem.String() + << ", expected '" + << kVersion40 + << "' or '" + << kVersion36 + << "'. Contents of " + << kParameterName + << " document in " + << NamespaceString::kServerConfigurationNamespace.toString() + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } if (fieldName == kVersionField) { @@ -107,18 +103,15 @@ FeatureCompatibilityVersionParser::parse(const BSONObj& featureCompatibilityVers } else { return Status( ErrorCodes::BadValue, - str::stream() - << "Unrecognized field '" - << fieldName - << "'. Contents of " - << kParameterName - << " document in " - << "admin.system.version" // TODO: NamespaceString constant (SERVER-33562) - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version_documentation::kCompatibilityLink - << "."); + str::stream() << "Unrecognized field '" << fieldName << "'. Contents of " + << kParameterName + << " document in " + << NamespaceString::kServerConfigurationNamespace.toString() + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } } @@ -134,34 +127,28 @@ FeatureCompatibilityVersionParser::parse(const BSONObj& featureCompatibilityVers if (targetVersionString == kVersion40 || targetVersionString == kVersion36) { return Status( ErrorCodes::BadValue, - str::stream() - << "Invalid state for " - << kParameterName - << " document in " - << "admin.system.version" // TODO: NamespaceString constant (SERVER-33562) - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version_documentation::kCompatibilityLink - << "."); + str::stream() << "Invalid state for " << kParameterName << " document in " + << NamespaceString::kServerConfigurationNamespace.toString() + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } else { version = ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo40; } } else { return Status( ErrorCodes::BadValue, - str::stream() - << "Missing required field '" - << kVersionField - << "''. Contents of " - << kParameterName - << " document in " - << "admin.system.version" // TODO: NamespaceString constant (SERVER-33562) - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version_documentation::kCompatibilityLink - << "."); + str::stream() << "Missing required field '" << kVersionField << "''. Contents of " + << kParameterName + << " document in " + << NamespaceString::kServerConfigurationNamespace.toString() + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } return version; diff --git a/src/mongo/db/commands/feature_compatibility_version_parser.h b/src/mongo/db/commands/feature_compatibility_version_parser.h index a1382623b6f..ac36f73556a 100644 --- a/src/mongo/db/commands/feature_compatibility_version_parser.h +++ b/src/mongo/db/commands/feature_compatibility_version_parser.h @@ -50,8 +50,9 @@ public: static constexpr StringData kTargetVersionField = "targetVersion"_sd; /** - * Parses the featureCompatibilityVersion document from admin.system.version, and returns the - * state represented by the combination of the targetVersion and version. + * Parses the featureCompatibilityVersion document from the server configuration collection + * (admin.system.version), and returns the state represented by the combination of the + * targetVersion and version. */ static StatusWith<ServerGlobalParams::FeatureCompatibility::Version> parse( const BSONObj& featureCompatibilityVersionDoc); diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp index 3f05d9cd2b9..391b7ac388e 100644 --- a/src/mongo/db/commands/rename_collection_cmd.cpp +++ b/src/mongo/db/commands/rename_collection_cmd.cpp @@ -144,11 +144,12 @@ public: return false; } - if (source.isAdminDotSystemDotVersion()) { - CommandHelpers::appendCommandStatus( - result, - Status(ErrorCodes::IllegalOperation, - "renaming admin.system.version is not allowed")); + if (source.isServerConfigurationCollection()) { + CommandHelpers::appendCommandStatus(result, + Status(ErrorCodes::IllegalOperation, + "renaming the server configuration " + "collection (admin.system.version) is not " + "allowed")); return false; } diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h index ad55b40aff6..a8fac0a2a58 100644 --- a/src/mongo/db/namespace_string.h +++ b/src/mongo/db/namespace_string.h @@ -72,7 +72,7 @@ public: // running as a replica set. Documents in this collection should represent some configuration // state of the server, which needs to be recovered/consulted at startup. Each document in this // namespace should have its _id set to some string, which meaningfully describes what it - // represents. + // represents. For example, 'shardIdentity' and 'featureCompatibilityVersion'. static const NamespaceString kServerConfigurationNamespace; // Namespace for storing the transaction information for each session @@ -224,7 +224,7 @@ public: bool isSystemDotViews() const { return coll() == kSystemDotViewsCollectionName; } - bool isAdminDotSystemDotVersion() const { + bool isServerConfigurationCollection() const { return (db() == kAdminDb) && (coll() == "system.version"); } bool isConfigDB() const { diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index c8a470f5b91..865fa0f09a7 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -395,7 +395,9 @@ void OpObserverImpl::onInserts(OperationContext* opCtx, Scope::storedFuncMod(opCtx); } else if (nss.coll() == DurableViewCatalog::viewsCollectionName()) { DurableViewCatalog::onExternalChange(opCtx, nss); - } else if (nss.ns() == FeatureCompatibilityVersion::kCollection) { + } else if (nss == NamespaceString::kServerConfigurationNamespace) { + // We must check server configuration collection writes for featureCompatibilityVersion + // document changes. for (auto it = first; it != last; it++) { FeatureCompatibilityVersion::onInsertOrUpdate(opCtx, it->doc); } @@ -457,7 +459,9 @@ void OpObserverImpl::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArg Scope::storedFuncMod(opCtx); } else if (args.nss.coll() == DurableViewCatalog::viewsCollectionName()) { DurableViewCatalog::onExternalChange(opCtx, args.nss); - } else if (args.nss.ns() == FeatureCompatibilityVersion::kCollection) { + } else if (args.nss == NamespaceString::kServerConfigurationNamespace) { + // We must check server configuration collection writes for featureCompatibilityVersion + // document changes. FeatureCompatibilityVersion::onInsertOrUpdate(opCtx, args.updatedDoc); } else if (args.nss == NamespaceString::kSessionTransactionsTableNamespace && !opTime.writeOpTime.isNull()) { @@ -511,7 +515,7 @@ void OpObserverImpl::onDelete(OperationContext* opCtx, Scope::storedFuncMod(opCtx); } else if (nss.coll() == DurableViewCatalog::viewsCollectionName()) { DurableViewCatalog::onExternalChange(opCtx, nss); - } else if (nss.isAdminDotSystemDotVersion()) { + } else if (nss.isServerConfigurationCollection()) { auto _id = deleteState.documentKey["_id"]; if (_id.type() == BSONType::String && _id.String() == FeatureCompatibilityVersionParser::kParameterName) @@ -666,9 +670,8 @@ void OpObserverImpl::onDropDatabase(OperationContext* opCtx, const std::string& kUninitializedStmtId, {}); - uassert(50714, - "dropping the admin database is not allowed.", - dbName != FeatureCompatibilityVersion::kDatabase); + uassert( + 50714, "dropping the admin database is not allowed.", dbName != NamespaceString::kAdminDb); if (dbName == NamespaceString::kSessionTransactionsTableNamespace.db()) { SessionCatalog::get(opCtx)->invalidateSessions(opCtx, boost::none); @@ -702,8 +705,8 @@ repl::OpTime OpObserverImpl::onDropCollection(OperationContext* opCtx, } uassert(50715, - "dropping the admin.system.version collection is not allowed.", - collectionName.ns() != FeatureCompatibilityVersion::kCollection); + "dropping the server configuration collection (admin.system.version) is not allowed.", + collectionName != NamespaceString::kServerConfigurationNamespace); if (collectionName.coll() == DurableViewCatalog::viewsCollectionName()) { DurableViewCatalog::onExternalChange(opCtx, collectionName); diff --git a/src/mongo/db/repair_database_and_check_version.cpp b/src/mongo/db/repair_database_and_check_version.cpp index d86c0da16af..214028ee19b 100644 --- a/src/mongo/db/repair_database_and_check_version.cpp +++ b/src/mongo/db/repair_database_and_check_version.cpp @@ -70,9 +70,10 @@ const std::string mustDowngradeErrorMsg = str::stream() Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx, const std::vector<std::string>& dbNames) { - NamespaceString fcvNss(FeatureCompatibilityVersion::kCollection); + NamespaceString fcvNss(NamespaceString::kServerConfigurationNamespace); - // If the admin database does not exist, create it. + // If the admin database, which contains the server configuration collection with the + // featureCompatibilityVersion document, does not exist, create it. Database* db = dbHolder().get(opCtx, fcvNss.db()); if (!db) { log() << "Re-creating admin database that was dropped."; @@ -80,14 +81,16 @@ Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx db = dbHolder().openDb(opCtx, fcvNss.db()); invariant(db); - // If admin.system.version does not exist, create it. - if (!db->getCollection(opCtx, FeatureCompatibilityVersion::kCollection)) { - log() << "Re-creating admin.system.version collection that was dropped."; + // If the server configuration collection, which contains the FCV document, does not exist, then + // create it. + if (!db->getCollection(opCtx, NamespaceString::kServerConfigurationNamespace)) { + log() << "Re-creating the server configuration collection (admin.system.version) that was " + "dropped."; uassertStatusOK( createCollection(opCtx, fcvNss.db().toString(), BSON("create" << fcvNss.coll()))); } - Collection* fcvColl = db->getCollection(opCtx, FeatureCompatibilityVersion::kCollection); + Collection* fcvColl = db->getCollection(opCtx, NamespaceString::kServerConfigurationNamespace); invariant(fcvColl); // Restore the featureCompatibilityVersion document if it is missing. @@ -284,12 +287,12 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { repairVerifiedAllCollectionsHaveUUIDs = true; // Attempt to restore the featureCompatibilityVersion document if it is missing. - NamespaceString nss(FeatureCompatibilityVersion::kCollection); + NamespaceString fcvNSS(NamespaceString::kServerConfigurationNamespace); - Database* db = dbHolder().get(opCtx, nss.db()); + Database* db = dbHolder().get(opCtx, fcvNSS.db()); Collection* versionColl; BSONObj featureCompatibilityVersion; - if (!db || !(versionColl = db->getCollection(opCtx, nss)) || + if (!db || !(versionColl = db->getCollection(opCtx, fcvNSS)) || !Helpers::findOne(opCtx, versionColl, BSON("_id" << FeatureCompatibilityVersionParser::kParameterName), @@ -407,11 +410,12 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { MONGO_UNREACHABLE; } - // Check if admin.system.version contains an invalid featureCompatibilityVersion. - // If a valid featureCompatibilityVersion is present, cache it as a server parameter. + + // If the server configuration collection already contains a valid + // featureCompatibilityVersion document, cache it in-memory as a server parameter. if (dbName == "admin") { if (Collection* versionColl = - db->getCollection(opCtx, FeatureCompatibilityVersion::kCollection)) { + db->getCollection(opCtx, NamespaceString::kServerConfigurationNamespace)) { BSONObj featureCompatibilityVersion; if (Helpers::findOne( opCtx, diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index d09428bf75d..68fb340da4b 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -18,7 +18,7 @@ env.Library( '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/background', '$BUILD_DIR/mongo/db/catalog/catalog_helpers', - '$BUILD_DIR/mongo/db/commands/dcommands_fcv', + '$BUILD_DIR/mongo/db/commands/feature_compatibility_version_parser', '$BUILD_DIR/mongo/db/db_raii', '$BUILD_DIR/mongo/db/dbdirectclient', '$BUILD_DIR/mongo/db/dbhelpers', @@ -1435,7 +1435,7 @@ env.Library( 'rollback_checker', 'storage_interface', '$BUILD_DIR/mongo/client/fetcher', - '$BUILD_DIR/mongo/db/commands/dcommands_fcv', + '$BUILD_DIR/mongo/db/commands/feature_compatibility_version_parser', ], ) diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index 7fac9df71c1..bec5848652e 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -41,7 +41,6 @@ #include "mongo/bson/util/bson_extract.h" #include "mongo/client/fetcher.h" #include "mongo/client/remote_command_retry_scheduler.h" -#include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/commands/feature_compatibility_version_parser.h" #include "mongo/db/commands/server_status_metric.h" #include "mongo/db/concurrency/d_concurrency.h" @@ -439,7 +438,7 @@ void InitialSyncer::_startInitialSyncAttemptCallback( LOG(2) << "Resetting feature compatibility version to last-stable. If the sync source is in " "latest feature compatibility version, we will find out when we clone the " - "admin.system.version collection."; + "server configuration collection (admin.system.version)."; serverGlobalParams.featureCompatibility.reset(); // Clear the oplog buffer. @@ -611,7 +610,7 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForBeginTimestamp( const auto& lastOpTimeWithHash = opTimeWithHashResult.getValue(); BSONObjBuilder queryBob; - queryBob.append("find", nsToCollectionSubstring(FeatureCompatibilityVersion::kCollection)); + queryBob.append("find", NamespaceString::kServerConfigurationNamespace.coll()); auto filterBob = BSONObjBuilder(queryBob.subobjStart("filter")); filterBob.append("_id", FeatureCompatibilityVersionParser::kParameterName); filterBob.done(); @@ -619,7 +618,7 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForBeginTimestamp( _fCVFetcher = stdx::make_unique<Fetcher>( _exec, _syncSource, - nsToDatabaseSubstring(FeatureCompatibilityVersion::kCollection).toString(), + NamespaceString::kServerConfigurationNamespace.db().toString(), queryBob.obj(), [=](const StatusWith<mongo::Fetcher::QueryResponse>& response, mongo::Fetcher::NextAction*, diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp index c4c8e26d72c..246c582a9f9 100644 --- a/src/mongo/db/repl/initial_syncer_test.cpp +++ b/src/mongo/db/repl/initial_syncer_test.cpp @@ -34,9 +34,9 @@ #include "mongo/client/fetcher.h" #include "mongo/db/client.h" -#include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/commands/feature_compatibility_version_parser.h" #include "mongo/db/json.h" +#include "mongo/db/namespace_string.h" #include "mongo/db/query/getmore_request.h" #include "mongo/db/repl/base_cloner_test_fixture.h" #include "mongo/db/repl/data_replicator_external_state_mock.h" @@ -571,9 +571,9 @@ void InitialSyncerTest::processSuccessfulLastOplogEntryFetcherResponse(std::vect } void assertFCVRequest(RemoteCommandRequest request) { - ASSERT_EQUALS(nsToDatabaseSubstring(FeatureCompatibilityVersion::kCollection), request.dbname) + ASSERT_EQUALS(NamespaceString::kServerConfigurationNamespace.db(), request.dbname) << request.toString(); - ASSERT_EQUALS(nsToCollectionSubstring(FeatureCompatibilityVersion::kCollection), + ASSERT_EQUALS(NamespaceString::kServerConfigurationNamespace.coll(), request.cmdObj.getStringField("find")); ASSERT_BSONOBJ_EQ(BSON("_id" << FeatureCompatibilityVersionParser::kParameterName), request.cmdObj.getObjectField("filter")); @@ -589,8 +589,8 @@ void InitialSyncerTest::processSuccessfulFCVFetcherResponse(std::vector<BSONObj> auto net = getNet(); auto request = assertRemoteCommandNameEquals( "find", - net->scheduleSuccessfulResponse(makeCursorResponse( - 0LL, NamespaceString(FeatureCompatibilityVersion::kCollection), docs))); + net->scheduleSuccessfulResponse( + makeCursorResponse(0LL, NamespaceString::kServerConfigurationNamespace, docs))); assertFCVRequest(request); net->runReadyNetworkOperations(); } @@ -1350,7 +1350,7 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughFCVFetcherScheduleError) { [&request](const executor::RemoteCommandRequest& requestToSend) { request = requestToSend; return "find" == requestToSend.cmdObj.firstElement().fieldNameStringData() && - nsToCollectionSubstring(FeatureCompatibilityVersion::kCollection) == + NamespaceString::kServerConfigurationNamespace.coll() == requestToSend.cmdObj.firstElement().str(); }; diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 32eda65ce6b..f0ea23b3b22 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -56,7 +56,6 @@ #include "mongo/db/catalog/uuid_catalog.h" #include "mongo/db/client.h" #include "mongo/db/commands.h" -#include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/commands/feature_compatibility_version_parser.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/db_raii.h" @@ -1052,10 +1051,10 @@ Status applyOperation_inlock(OperationContext* opCtx, collection = db->getCollection(opCtx, requestNss); } - // During upgrade from 3.4 to 3.6, the feature compatibility version cannot change during - // initial sync because we cannot do some operations with UUIDs and others without. + // The feature compatibility version in the server configuration collection must not change + // during initial sync. if ((mode == OplogApplication::Mode::kInitialSync) && - requestNss.ns() == FeatureCompatibilityVersion::kCollection) { + requestNss == NamespaceString::kServerConfigurationNamespace) { std::string oID; auto status = bsonExtractStringField(o, "_id", &oID); if (status.isOK() && oID == FeatureCompatibilityVersionParser::kParameterName) { @@ -1480,7 +1479,8 @@ Status applyCommand_inlock(OperationContext* opCtx, } } - // The feature compatibility version cannot change during initial sync. + // The feature compatibility version in the server configuration collection cannot change during + // initial sync. // We do not attempt to parse the whitelisted ops because they do not have a collection // namespace. If we drop the 'admin' database we will also log a 'drop' oplog entry for each // collection dropped. 'applyOps' will try to apply each individual operation, and those @@ -1489,7 +1489,7 @@ Status applyCommand_inlock(OperationContext* opCtx, if ((mode == OplogApplication::Mode::kInitialSync) && (std::find(whitelistedOps.begin(), whitelistedOps.end(), o.firstElementFieldName()) == whitelistedOps.end()) && - parseNs(nss.ns(), o).ns() == FeatureCompatibilityVersion::kCollection) { + parseNs(nss.ns(), o) == NamespaceString::kServerConfigurationNamespace) { return Status(ErrorCodes::OplogOperationUnsupported, str::stream() << "Applying command to feature compatibility version " "collection not supported in initial sync: " diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp index 68359c36229..063ee21205f 100644 --- a/src/mongo/db/repl/sync_tail_test.cpp +++ b/src/mongo/db/repl/sync_tail_test.cpp @@ -41,7 +41,6 @@ #include "mongo/db/catalog/database_holder.h" #include "mongo/db/catalog/document_validation.h" #include "mongo/db/client.h" -#include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/commands/feature_compatibility_version_parser.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/write_conflict_exception.h" @@ -1653,15 +1652,14 @@ TEST_F(SyncTailTest, FailOnDropFCVCollection) { ASSERT_OK( ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_RECOVERING)); - auto fcvNS = NamespaceString(FeatureCompatibilityVersion::kCollection); + auto fcvNS(NamespaceString::kServerConfigurationNamespace); auto cmd = BSON("drop" << fcvNS.coll()); - auto op = makeCommandOplogEntry( - nextOpTime(), NamespaceString(FeatureCompatibilityVersion::kCollection), cmd); + auto op = makeCommandOplogEntry(nextOpTime(), fcvNS, cmd); ASSERT_EQUALS(runOpInitialSync(op), ErrorCodes::OplogOperationUnsupported); } TEST_F(SyncTailTest, FailOnInsertFCVDocument) { - auto fcvNS = NamespaceString(FeatureCompatibilityVersion::kCollection); + auto fcvNS(NamespaceString::kServerConfigurationNamespace); ::mongo::repl::createCollection(_opCtx.get(), fcvNS, CollectionOptions()); ASSERT_OK( ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_RECOVERING)); @@ -1672,7 +1670,7 @@ TEST_F(SyncTailTest, FailOnInsertFCVDocument) { } TEST_F(IdempotencyTest, InsertToFCVCollectionBesidesFCVDocumentSucceeds) { - auto fcvNS = NamespaceString(FeatureCompatibilityVersion::kCollection); + auto fcvNS(NamespaceString::kServerConfigurationNamespace); ::mongo::repl::createCollection(_opCtx.get(), fcvNS, CollectionOptions()); ASSERT_OK( ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_RECOVERING)); 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 179e0212794..a6e50420b6b 100644 --- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp @@ -38,7 +38,6 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/commands.h" -#include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/hasher.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/namespace_string.h" diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index 7765a3579a0..e9ea5c752d1 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -146,8 +146,9 @@ struct ServerGlobalParams { struct FeatureCompatibility { /** - * The combination of the fields in the admin.system.version document in the format - * (version, targetVersion) are represented by this enum and determine this node's behavior. + * The combination of the fields (version, targetVersion) in the featureCompatiiblityVersion + * document in the server configuration collection (admin.system.version) are represented by + * this enum and determine this node's behavior. * * Features can be gated for specific versions, or ranges of versions above or below some * minimum or maximum version, respectively. |