diff options
author | Benety Goh <benety@mongodb.com> | 2018-12-20 23:34:46 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2018-12-20 23:35:03 -0500 |
commit | 4270e87c62a2c7ea365b20bb37ede7e3888ad0ed (patch) | |
tree | 2d5b891bb3934dfaa09e87d3294a7653e401b7d1 /src/mongo/db | |
parent | 3c140cdd63bbf20e585bbbccd21ed3ea64e656b1 (diff) | |
download | mongo-4270e87c62a2c7ea365b20bb37ede7e3888ad0ed.tar.gz |
SERVER-38719 rename DatabaseHolder::get() to getDb()
Repurpose DatabaseHolder::get() for accessing singleton.
Deprecate DatabaseHolder::getDatabaseHolder().
Diffstat (limited to 'src/mongo/db')
41 files changed, 129 insertions, 83 deletions
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp index 96b566d3d72..122630ef4e4 100644 --- a/src/mongo/db/catalog/catalog_control.cpp +++ b/src/mongo/db/catalog/catalog_control.cpp @@ -52,9 +52,9 @@ MinVisibleTimestampMap closeCatalog(OperationContext* opCtx) { std::vector<std::string> allDbs; opCtx->getServiceContext()->getStorageEngine()->listDatabases(&allDbs); - const auto& databaseHolder = DatabaseHolder::getDatabaseHolder(); + auto databaseHolder = DatabaseHolder::get(opCtx); for (auto&& dbName : allDbs) { - const auto db = databaseHolder.get(opCtx, dbName); + const auto db = databaseHolder->getDb(opCtx, dbName); for (Collection* coll : *db) { OptionalCollectionUUID uuid = coll->uuid(); boost::optional<Timestamp> minVisible = coll->getMinimumVisibleSnapshot(); @@ -81,7 +81,7 @@ MinVisibleTimestampMap closeCatalog(OperationContext* opCtx) { // Close all databases. log() << "closeCatalog: closing all databases"; constexpr auto reason = "closing databases for closeCatalog"; - DatabaseHolder::getDatabaseHolder().closeAll(opCtx, reason); + databaseHolder->closeAll(opCtx, reason); // Close the storage engine's catalog. log() << "closeCatalog: closing storage engine catalog"; @@ -169,11 +169,12 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib // Open all databases and repopulate the UUID catalog. log() << "openCatalog: reopening all databases"; auto& uuidCatalog = UUIDCatalog::get(opCtx); + auto databaseHolder = DatabaseHolder::get(opCtx); std::vector<std::string> databasesToOpen; storageEngine->listDatabases(&databasesToOpen); for (auto&& dbName : databasesToOpen) { LOG(1) << "openCatalog: dbholder reopening database " << dbName; - auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto db = databaseHolder->openDb(opCtx, dbName); invariant(db, str::stream() << "failed to reopen database " << dbName); std::list<std::string> collections; diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp index da1ef258d4b..c2d7d8fb4b6 100644 --- a/src/mongo/db/catalog/create_collection.cpp +++ b/src/mongo/db/catalog/create_collection.cpp @@ -153,8 +153,8 @@ Status createCollectionForApplyOps(OperationContext* opCtx, const NamespaceString newCollName(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); auto newCmd = cmdObj; - auto* const serviceContext = opCtx->getServiceContext(); - auto* const db = DatabaseHolder::getDatabaseHolder().get(opCtx, dbName); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto* const db = databaseHolder->getDb(opCtx, dbName); // If a UUID is given, see if we need to rename a collection out of the way, and whether the // collection already exists under a different name. If so, rename it into place. As this is @@ -177,7 +177,8 @@ Status createCollectionForApplyOps(OperationContext* opCtx, auto& catalog = UUIDCatalog::get(opCtx); const auto currentName = catalog.lookupNSSByUUID(uuid); - OpObserver* const opObserver = serviceContext->getOpObserver(); + auto serviceContext = opCtx->getServiceContext(); + auto opObserver = serviceContext->getOpObserver(); if (currentName == newCollName) return Result(Status::OK()); diff --git a/src/mongo/db/catalog/database_holder.cpp b/src/mongo/db/catalog/database_holder.cpp index ee2b4f31cbc..8ac6faf5029 100644 --- a/src/mongo/db/catalog/database_holder.cpp +++ b/src/mongo/db/catalog/database_holder.cpp @@ -36,4 +36,8 @@ namespace mongo { MONGO_DEFINE_SHIM(DatabaseHolder::getDatabaseHolder); +DatabaseHolder* DatabaseHolder::get(OperationContext* opCtx) { + return &getDatabaseHolder(); +} + } // namespace mongo diff --git a/src/mongo/db/catalog/database_holder.h b/src/mongo/db/catalog/database_holder.h index 02cc0cafe93..e4eb079501d 100644 --- a/src/mongo/db/catalog/database_holder.h +++ b/src/mongo/db/catalog/database_holder.h @@ -52,16 +52,17 @@ class RecordStore; class DatabaseHolder { public: static MONGO_DECLARE_SHIM(()->DatabaseHolder&) getDatabaseHolder; + static DatabaseHolder* get(OperationContext* opCtx); virtual ~DatabaseHolder() = default; DatabaseHolder() = default; /** - * Retrieves an already opened database or returns NULL. Must be called with the database + * Retrieves an already opened database or returns nullptr. Must be called with the database * locked in at least IS-mode. */ - virtual Database* get(OperationContext* const opCtx, const StringData ns) const = 0; + virtual Database* getDb(OperationContext* const opCtx, const StringData ns) const = 0; /** * Retrieves a database reference if it is already opened, or opens it if it hasn't been diff --git a/src/mongo/db/catalog/database_holder_impl.cpp b/src/mongo/db/catalog/database_holder_impl.cpp index 24804ac4b05..0cd5ed72b08 100644 --- a/src/mongo/db/catalog/database_holder_impl.cpp +++ b/src/mongo/db/catalog/database_holder_impl.cpp @@ -83,7 +83,7 @@ StringData _todb(StringData ns) { } // namespace -Database* DatabaseHolderImpl::get(OperationContext* opCtx, StringData ns) const { +Database* DatabaseHolderImpl::getDb(OperationContext* opCtx, StringData ns) const { const StringData db = _todb(ns); invariant(opCtx->lockState()->isDbLockedForMode(db, MODE_IS)); diff --git a/src/mongo/db/catalog/database_holder_impl.h b/src/mongo/db/catalog/database_holder_impl.h index 20f5f752709..29b63a8e8ef 100644 --- a/src/mongo/db/catalog/database_holder_impl.h +++ b/src/mongo/db/catalog/database_holder_impl.h @@ -41,7 +41,7 @@ class DatabaseHolderImpl : public DatabaseHolder { public: DatabaseHolderImpl() = default; - Database* get(OperationContext* opCtx, StringData ns) const override; + Database* getDb(OperationContext* opCtx, StringData ns) const override; Database* openDb(OperationContext* opCtx, StringData ns, bool* justCreated = nullptr) override; diff --git a/src/mongo/db/catalog/database_holder_mock.h b/src/mongo/db/catalog/database_holder_mock.h index 6a1f6bae94e..dc04fffdf3d 100644 --- a/src/mongo/db/catalog/database_holder_mock.h +++ b/src/mongo/db/catalog/database_holder_mock.h @@ -38,7 +38,7 @@ class DatabaseHolderMock : public DatabaseHolder { public: DatabaseHolderMock() = default; - Database* get(OperationContext* opCtx, StringData ns) const override { + Database* getDb(OperationContext* opCtx, StringData ns) const override { return nullptr; } diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp index 49328d12c0e..6768d514d37 100644 --- a/src/mongo/db/catalog/drop_database.cpp +++ b/src/mongo/db/catalog/drop_database.cpp @@ -66,7 +66,8 @@ Status _finishDropDatabase(OperationContext* opCtx, const std::string& dbName, D // If DatabaseHolder::dropDb() fails, we should reset the drop-pending state on Database. auto dropPendingGuard = MakeGuard([db, opCtx] { db->setDropPending(opCtx, false); }); - DatabaseHolder::getDatabaseHolder().dropDb(opCtx, db); + auto databaseHolder = DatabaseHolder::get(opCtx); + databaseHolder->dropDb(opCtx, db); dropPendingGuard.Dismiss(); log() << "dropDatabase " << dbName << " - finished"; diff --git a/src/mongo/db/catalog/drop_database_test.cpp b/src/mongo/db/catalog/drop_database_test.cpp index 26085d26c40..61a62c098af 100644 --- a/src/mongo/db/catalog/drop_database_test.cpp +++ b/src/mongo/db/catalog/drop_database_test.cpp @@ -201,7 +201,8 @@ void _removeDatabaseFromCatalog(OperationContext* opCtx, StringData dbName) { // dropDatabase can call awaitReplication more than once, so do not attempt to drop the database // twice. if (db) { - DatabaseHolder::getDatabaseHolder().dropDb(opCtx, db); + auto databaseHolder = DatabaseHolder::get(opCtx); + databaseHolder->dropDb(opCtx, db); } } diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index 17511b348b5..c9b000ec5a4 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -160,7 +160,8 @@ Status renameCollectionCommon(OperationContext* opCtx, << target.ns()); } - Database* const sourceDB = DatabaseHolder::getDatabaseHolder().get(opCtx, source.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto sourceDB = databaseHolder->getDb(opCtx, source.db()); if (sourceDB) { DatabaseShardingState::get(sourceDB).checkDbVersion(opCtx); } @@ -204,7 +205,7 @@ Status renameCollectionCommon(OperationContext* opCtx, BackgroundOperation::assertNoBgOpInProgForNs(source.ns()); - Database* const targetDB = DatabaseHolder::getDatabaseHolder().openDb(opCtx, target.db()); + auto targetDB = databaseHolder->openDb(opCtx, target.db()); // Check if the target namespace exists and if dropTarget is true. // Return a non-OK status if target exists and dropTarget is not true or if the collection diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp index e0f6bd2e09d..982d8d52b6a 100644 --- a/src/mongo/db/catalog/rename_collection_test.cpp +++ b/src/mongo/db/catalog/rename_collection_test.cpp @@ -449,7 +449,8 @@ void _insertDocument(OperationContext* opCtx, const NamespaceString& nss, const */ Collection* _getCollection_inlock(OperationContext* opCtx, const NamespaceString& nss) { invariant(opCtx->lockState()->isCollectionLockedForMode(nss.ns(), MODE_IS)); - auto* db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto* db = databaseHolder->getDb(opCtx, nss.db()); if (!db) { return nullptr; } diff --git a/src/mongo/db/catalog_raii.cpp b/src/mongo/db/catalog_raii.cpp index e058bf48034..342c4d60a61 100644 --- a/src/mongo/db/catalog_raii.cpp +++ b/src/mongo/db/catalog_raii.cpp @@ -55,7 +55,8 @@ void uassertLockTimeout(std::string resourceName, LockMode lockMode, bool isLock AutoGetDb::AutoGetDb(OperationContext* opCtx, StringData dbName, LockMode mode, Date_t deadline) : _dbLock(opCtx, dbName, mode, deadline), _db([&] { uassertLockTimeout(str::stream() << "database " << dbName, mode, _dbLock.isLocked()); - return DatabaseHolder::getDatabaseHolder().get(opCtx, dbName); + auto databaseHolder = DatabaseHolder::get(opCtx); + return databaseHolder->getDb(opCtx, dbName); }()) { if (_db) { DatabaseShardingState::get(_db).checkDbVersion(opCtx); @@ -166,7 +167,8 @@ AutoGetOrCreateDb::AutoGetOrCreateDb(OperationContext* opCtx, _autoDb.emplace(opCtx, dbName, MODE_X, deadline); } - _db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName, &_justCreated); + auto databaseHolder = DatabaseHolder::get(opCtx); + _db = databaseHolder->openDb(opCtx, dbName, &_justCreated); } DatabaseShardingState::get(_db).checkDbVersion(opCtx); diff --git a/src/mongo/db/catalog_raii.h b/src/mongo/db/catalog_raii.h index 4bb0a610c44..191dcce52c8 100644 --- a/src/mongo/db/catalog_raii.h +++ b/src/mongo/db/catalog_raii.h @@ -43,7 +43,7 @@ namespace mongo { /** * RAII-style class, which acquires a lock on the specified database in the requested mode and * obtains a reference to the database. Used as a shortcut for calls to - * DatabaseHolder::getDatabaseHolder().get(). + * DatabaseHolder::get(opCtx)->get(). * * Use this when you want to do a database-level operation, like read a list of all collections, or * drop a collection. @@ -155,7 +155,7 @@ private: /** * RAII-style class, which acquires a lock on the specified database in the requested mode and * obtains a reference to the database, creating it was non-existing. Used as a shortcut for - * calls to DatabaseHolder::getDatabaseHolder().openDb(), taking care of locking details. The + * calls to DatabaseHolder::get(opCtx)->openDb(), taking care of locking details. The * requested mode must be MODE_IX or MODE_X. If the database needs to be created, the lock will * automatically be reacquired as MODE_X. * diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index e3f65aa2ffa..d248aeae42d 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -142,7 +142,8 @@ struct Cloner::Fun { repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, to_collection)); // Make sure database still exists after we resume from the temp release - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, _dbName); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, _dbName); bool createdCollection = false; Collection* collection = NULL; @@ -205,7 +206,7 @@ struct Cloner::Fun { } // TODO: SERVER-16598 abort if original db or collection is gone. - db = DatabaseHolder::getDatabaseHolder().get(opCtx, _dbName); + db = databaseHolder->getDb(opCtx, _dbName); uassert(28593, str::stream() << "Database " << _dbName << " dropped while cloning", db != NULL); @@ -365,7 +366,8 @@ void Cloner::copyIndexes(OperationContext* opCtx, // We are under lock here again, so reload the database in case it may have disappeared // during the temp release - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, toDBName); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, toDBName); Collection* collection = db->getCollection(opCtx, to_collection); if (!collection) { @@ -480,7 +482,8 @@ bool Cloner::copyCollection(OperationContext* opCtx, !opCtx->writesAreReplicated() || repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss)); - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbname); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, dbname); if (shouldCreateCollection) { bool result = writeConflictRetry(opCtx, "createCollection", ns, [&] { @@ -570,7 +573,8 @@ Status Cloner::createCollectionsForDb( const std::vector<CreateCollectionParams>& createCollectionParams, const std::string& dbName, const CloneOptions& opts) { - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, dbName); invariant(opCtx->lockState()->isDbLockedForMode(dbName, MODE_X)); auto collCount = 0; diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 2edd7fc6d5a..aac92fa46c4 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -316,9 +316,10 @@ bool runCreateIndexes(OperationContext* opCtx, // not allow locks or re-locks to be interrupted. UninterruptibleLockGuard noInterrupt(opCtx->lockState()); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, ns.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, ns.db()); if (!db) { - db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, ns.db()); + db = databaseHolder->openDb(opCtx, ns.db()); } DatabaseShardingState::get(db).checkDbVersion(opCtx); @@ -451,7 +452,7 @@ bool runCreateIndexes(OperationContext* opCtx, opCtx->recoveryUnit()->abandonSnapshot(); dbLock.relockWithMode(MODE_X); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, ns.db()); + auto db = databaseHolder->getDb(opCtx, ns.db()); if (db) { DatabaseShardingState::get(db).checkDbVersion(opCtx); } diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp index 7c715eeacb4..5151c566467 100644 --- a/src/mongo/db/commands/dbcommands_d.cpp +++ b/src/mongo/db/commands/dbcommands_d.cpp @@ -132,7 +132,8 @@ protected: if (!db) { // When setting the profiling level, create the database if it didn't already exist. // When just reading the profiling level, we do not create the database. - db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto databaseHolder = DatabaseHolder::get(opCtx); + db = databaseHolder->openDb(opCtx, dbName); } uassertStatusOK(db->setProfilingLevel(opCtx, profilingLevel)); } diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 6d3ad0e9a50..6a09c83bbc0 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -108,7 +108,8 @@ unsigned long long collectionCount(OperationContext* opCtx, // If the global write lock is held, we must avoid using AutoGetCollectionForReadCommand as it // may lead to deadlock when waiting for a majority snapshot to be committed. See SERVER-24596. if (callerHoldsGlobalLock) { - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.ns()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, nss.ns()); if (db) { coll = db->getCollection(opCtx, nss); } @@ -467,8 +468,8 @@ void State::dropTempCollections() { if (_useIncremental && !_config.incLong.isEmpty()) { writeConflictRetry(_opCtx, "M/R dropTempCollections", _config.incLong.ns(), [this] { Lock::DBLock lk(_opCtx, _config.incLong.db(), MODE_X); - if (Database* db = - DatabaseHolder::getDatabaseHolder().get(_opCtx, _config.incLong.ns())) { + auto databaseHolder = DatabaseHolder::get(_opCtx); + if (auto db = databaseHolder->getDb(_opCtx, _config.incLong.ns())) { WriteUnitOfWork wunit(_opCtx); uassertStatusOK(db->dropCollection(_opCtx, _config.incLong.ns())); wunit.commit(); diff --git a/src/mongo/db/commands/resize_oplog.cpp b/src/mongo/db/commands/resize_oplog.cpp index 95abdb5677d..cdae013bf44 100644 --- a/src/mongo/db/commands/resize_oplog.cpp +++ b/src/mongo/db/commands/resize_oplog.cpp @@ -84,7 +84,8 @@ public: BSONObjBuilder& result) { const NamespaceString nss("local", "oplog.rs"); Lock::GlobalWrite global(opCtx); - Database* database = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto database = databaseHolder->getDb(opCtx, nss.db()); if (!database) { uasserted(ErrorCodes::NamespaceNotFound, "database local does not exist"); } diff --git a/src/mongo/db/commands/restart_catalog_command.cpp b/src/mongo/db/commands/restart_catalog_command.cpp index b2b543d99b8..da72aeb2b18 100644 --- a/src/mongo/db/commands/restart_catalog_command.cpp +++ b/src/mongo/db/commands/restart_catalog_command.cpp @@ -94,10 +94,11 @@ public: // This command will fail without modifying the catalog if there are any databases that are // marked drop-pending. (Otherwise, the Database object will be reconstructed when // re-opening the catalog, but with the drop pending flag cleared.) + auto databaseHolder = DatabaseHolder::get(opCtx); std::vector<std::string> allDbs; getGlobalServiceContext()->getStorageEngine()->listDatabases(&allDbs); for (auto&& dbName : allDbs) { - const auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, dbName); + const auto db = databaseHolder->getDb(opCtx, dbName); if (db->isDropPending(opCtx)) { uasserted(ErrorCodes::DatabaseDropPending, str::stream() << "cannot restart the catalog because database " << dbName diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp index 2d3279dc41e..f078ccf4966 100644 --- a/src/mongo/db/db_raii.cpp +++ b/src/mongo/db/db_raii.cpp @@ -279,11 +279,11 @@ AutoGetCollectionForReadCommand::AutoGetCollectionForReadCommand( } OldClientContext::OldClientContext(OperationContext* opCtx, const std::string& ns, bool doVersion) - : _opCtx(opCtx), _db(DatabaseHolder::getDatabaseHolder().get(opCtx, ns)) { + : _opCtx(opCtx), _db(DatabaseHolder::get(opCtx)->getDb(opCtx, ns)) { if (!_db) { const auto dbName = nsToDatabaseSubstring(ns); invariant(_opCtx->lockState()->isDbLockedForMode(dbName, MODE_X)); - _db = DatabaseHolder::getDatabaseHolder().openDb(_opCtx, dbName, &_justCreated); + _db = DatabaseHolder::get(opCtx)->openDb(_opCtx, dbName, &_justCreated); invariant(_db); } diff --git a/src/mongo/db/exec/requires_collection_stage.h b/src/mongo/db/exec/requires_collection_stage.h index 706fe90cf75..677336e1fb2 100644 --- a/src/mongo/db/exec/requires_collection_stage.h +++ b/src/mongo/db/exec/requires_collection_stage.h @@ -94,7 +94,8 @@ private: // collection pointer 'coll' must be non-null and must point to a valid collection. uint64_t getDatabaseEpoch(CollectionT coll) const { invariant(coll); - auto db = DatabaseHolder::getDatabaseHolder().get(getOpCtx(), coll->ns().ns()); + auto databaseHolder = DatabaseHolder::get(getOpCtx()); + auto db = databaseHolder->getDb(getOpCtx(), coll->ns().ns()); invariant(db); return db->epoch(); } diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index e620585696d..1adda2e4af3 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -158,7 +158,8 @@ void IndexBuilder::run() { NamespaceString ns(_index["ns"].String()); Lock::DBLock dlk(opCtx.get(), ns.db(), MODE_X); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx.get(), ns.db().toString()); + auto databaseHolder = DatabaseHolder::get(opCtx.get()); + auto db = databaseHolder->getDb(opCtx.get(), ns.db().toString()); // This background index build can only be interrupted at shutdown. // For the duration of the OperationContext::runWithoutInterruption() invocation, any kill @@ -359,7 +360,8 @@ Status IndexBuilder::_build(OperationContext* opCtx, << ns.ns() << ": " << _index); - Database* reloadDb = DatabaseHolder::getDatabaseHolder().get(opCtx, ns.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto reloadDb = databaseHolder->getDb(opCtx, ns.db()); fassert(28553, reloadDb); fassert(28554, reloadDb->getCollection(opCtx, ns)); } diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index 8aa83617d58..524157fafa1 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -686,7 +686,8 @@ void OpObserverImpl::onCollMod(OperationContext* opCtx, // Make sure the UUID values in the Collection metadata, the Collection object, and the UUID // catalog are all present and equal. invariant(opCtx->lockState()->isDbLockedForMode(nss.db(), MODE_X)); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, nss.db()); // Some unit tests call the op observer on an unregistered Database. if (!db) { return; diff --git a/src/mongo/db/pipeline/process_interface_standalone.cpp b/src/mongo/db/pipeline/process_interface_standalone.cpp index 70330f1fe3b..3072269edba 100644 --- a/src/mongo/db/pipeline/process_interface_standalone.cpp +++ b/src/mongo/db/pipeline/process_interface_standalone.cpp @@ -495,10 +495,9 @@ bool MongoInterfaceStandalone::uniqueKeyIsSupportedByIndex( // the catalog. Lock::DBLock dbLock(opCtx, nss.db(), MODE_IS); Lock::CollectionLock collLock(opCtx->lockState(), nss.ns(), MODE_IS); - const auto* collection = [&]() -> Collection* { - auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db()); - return db ? db->getCollection(opCtx, nss) : nullptr; - }(); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, nss.db()); + auto collection = db ? db->getCollection(opCtx, nss) : nullptr; if (!collection) { return uniqueKeyPaths == std::set<FieldPath>{"_id"}; } diff --git a/src/mongo/db/query/plan_executor_impl.cpp b/src/mongo/db/query/plan_executor_impl.cpp index fd3dc43b110..b8b31dbac62 100644 --- a/src/mongo/db/query/plan_executor_impl.cpp +++ b/src/mongo/db/query/plan_executor_impl.cpp @@ -456,7 +456,8 @@ std::shared_ptr<CappedInsertNotifier> PlanExecutorImpl::_getCappedInsertNotifier // We can only wait if we have a collection; otherwise we should retry immediately when // we hit EOF. dassert(_opCtx->lockState()->isCollectionLockedForMode(_nss.ns(), MODE_IS)); - auto db = DatabaseHolder::getDatabaseHolder().get(_opCtx, _nss.db()); + auto databaseHolder = DatabaseHolder::get(_opCtx); + auto db = databaseHolder->getDb(_opCtx, _nss.db()); invariant(db); auto collection = db->getCollection(_opCtx, _nss); invariant(collection); diff --git a/src/mongo/db/repair_database.cpp b/src/mongo/db/repair_database.cpp index 39766594f89..abbb2e94b6f 100644 --- a/src/mongo/db/repair_database.cpp +++ b/src/mongo/db/repair_database.cpp @@ -121,8 +121,6 @@ Status rebuildIndexesOnCollection(OperationContext* opCtx, if (indexSpecs.empty()) return Status::OK(); - auto dbHolder = &DatabaseHolder::getDatabaseHolder(); - const auto& ns = cce->ns().ns(); auto rs = dbce->getRecordStore(ns); @@ -149,7 +147,8 @@ Status rebuildIndexesOnCollection(OperationContext* opCtx, // open a bad index and fail. // TODO see if MultiIndexBlock can be made to work without a Collection. const auto uuid = cce->getCollectionOptions(opCtx).uuid; - collection = dbHolder->makeCollection(opCtx, ns, uuid, cce, rs, dbce); + auto databaseHolder = DatabaseHolder::get(opCtx); + collection = databaseHolder->makeCollection(opCtx, ns, uuid, cce, rs, dbce); indexer = std::make_unique<MultiIndexBlock>(opCtx, collection.get()); Status status = indexer->init(indexSpecs).getStatus(); @@ -280,14 +279,15 @@ Status repairDatabase(OperationContext* opCtx, StorageEngine* engine, const std: opCtx->checkForInterrupt(); // Close the db and invalidate all current users and caches. - DatabaseHolder::getDatabaseHolder().close(opCtx, dbName, "database closed for repair"); - ON_BLOCK_EXIT([&dbName, &opCtx] { + auto databaseHolder = DatabaseHolder::get(opCtx); + databaseHolder->close(opCtx, dbName, "database closed for repair"); + ON_BLOCK_EXIT([databaseHolder, &dbName, &opCtx] { try { // Ensure that we don't trigger an exception when attempting to take locks. UninterruptibleLockGuard noInterrupt(opCtx->lockState()); // Open the db after everything finishes. - auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto db = databaseHolder->openDb(opCtx, dbName); // Set the minimum snapshot for all Collections in this db. This ensures that readers // using majority readConcern level can only use the collections after their repaired diff --git a/src/mongo/db/repair_database_and_check_version.cpp b/src/mongo/db/repair_database_and_check_version.cpp index 8ca17635703..0c134d8c26d 100644 --- a/src/mongo/db/repair_database_and_check_version.cpp +++ b/src/mongo/db/repair_database_and_check_version.cpp @@ -77,11 +77,12 @@ Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx // If the admin database, which contains the server configuration collection with the // featureCompatibilityVersion document, does not exist, create it. - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, fcvNss.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, fcvNss.db()); if (!db) { log() << "Re-creating admin database that was dropped."; } - db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, fcvNss.db()); + db = databaseHolder->openDb(opCtx, fcvNss.db()); invariant(db); // If the server configuration collection, which contains the FCV document, does not exist, then @@ -134,8 +135,9 @@ Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx */ Status ensureAllCollectionsHaveUUIDs(OperationContext* opCtx, const std::vector<std::string>& dbNames) { + auto databaseHolder = DatabaseHolder::get(opCtx); for (const auto& dbName : dbNames) { - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto db = databaseHolder->openDb(opCtx, dbName); invariant(db); for (auto collectionIt = db->begin(); collectionIt != db->end(); ++collectionIt) { Collection* coll = *collectionIt; @@ -262,6 +264,7 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { bool repairVerifiedAllCollectionsHaveUUIDs = false; // Repair all databases first, so that we do not try to open them if they are in bad shape + auto databaseHolder = DatabaseHolder::get(opCtx); if (storageGlobalParams.repair) { invariant(!storageGlobalParams.readOnly); @@ -286,7 +289,7 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { // Attempt to restore the featureCompatibilityVersion document if it is missing. NamespaceString fcvNSS(NamespaceString::kServerConfigurationNamespace); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, fcvNSS.db()); + auto db = databaseHolder->getDb(opCtx, fcvNSS.db()); Collection* versionColl; BSONObj featureCompatibilityVersion; if (!db || !(versionColl = db->getCollection(opCtx, fcvNSS)) || @@ -317,7 +320,7 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { // "local" database and populate the catalog entries because we won't attempt to drop the // temporary collections anyway. Lock::DBLock dbLock(opCtx, kSystemReplSetCollection.db(), MODE_X); - DatabaseHolder::getDatabaseHolder().openDb(opCtx, kSystemReplSetCollection.db()); + databaseHolder->openDb(opCtx, kSystemReplSetCollection.db()); } if (storageGlobalParams.repair) { @@ -367,7 +370,7 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { } LOG(1) << " Recovering database: " << dbName; - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto db = databaseHolder->openDb(opCtx, dbName); invariant(db); // First thing after opening the database is to check for file compatibility, diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp index 92772a91fc8..a32a0d212c1 100644 --- a/src/mongo/db/repl/apply_ops.cpp +++ b/src/mongo/db/repl/apply_ops.cpp @@ -136,7 +136,8 @@ Status _applyOps(OperationContext* opCtx, // ApplyOps does not have the global writer lock when applying transaction // operations, so we need to acquire the DB and Collection locks. Lock::DBLock dbLock(opCtx, nss.db(), MODE_IX); - auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.ns()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, nss.ns()); if (!db) { // Retry in non-atomic mode, since MMAP cannot implicitly create a new database // within an active WriteUnitOfWork. @@ -369,7 +370,8 @@ Status _checkPrecondition(OperationContext* opCtx, BSONObj realres = db.findOne(nss.ns(), preCondition["q"].Obj()); // Get collection default collation. - Database* database = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto database = databaseHolder->getDb(opCtx, nss.db()); if (!database) { return {ErrorCodes::NamespaceNotFound, "database in ns does not exist: " + nss.ns()}; } diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index a7e71360afc..3c8078cd4fc 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -236,7 +236,8 @@ void createIndexForApplyOps(OperationContext* opCtx, dbLock.emplace(opCtx, indexNss.db(), MODE_X); } // Check if collection exists. - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, indexNss.ns()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, indexNss.ns()); auto indexCollection = db ? db->getCollection(opCtx, indexNss) : nullptr; uassert(ErrorCodes::NamespaceNotFound, str::stream() << "Failed to create index due to missing collection: " << indexNss.ns(), @@ -1562,7 +1563,8 @@ Status applyCommand_inlock(OperationContext* opCtx, // Command application doesn't always acquire the global writer lock for transaction // commands, so we acquire its own locks here. Lock::DBLock lock(opCtx, nss.db(), MODE_IS); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, nss.ns()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, nss.ns()); if (db && !db->getCollection(opCtx, nss) && db->getViewCatalog()->lookup(opCtx, nss.ns())) { return {ErrorCodes::CommandNotSupportedOnView, str::stream() << "applyOps not supported on view:" << nss.ns()}; diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp index 00210676118..a7dddcfdf3f 100644 --- a/src/mongo/db/repl/rollback_impl.cpp +++ b/src/mongo/db/repl/rollback_impl.cpp @@ -913,9 +913,10 @@ void RollbackImpl::_resetDropPendingState(OperationContext* opCtx) { std::vector<std::string> dbNames; storageEngine->listDatabases(&dbNames); + auto databaseHolder = DatabaseHolder::get(opCtx); for (const auto& dbName : dbNames) { Lock::DBLock dbLock(opCtx, dbName, MODE_X); - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto db = databaseHolder->openDb(opCtx, dbName); db->checkForIdIndexesAndDropPendingCollections(opCtx); } } diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp index b9228638e07..c6644d81249 100644 --- a/src/mongo/db/repl/rollback_test_fixture.cpp +++ b/src/mongo/db/repl/rollback_test_fixture.cpp @@ -187,7 +187,8 @@ Collection* RollbackTest::_createCollection(OperationContext* opCtx, const CollectionOptions& options) { Lock::DBLock dbLock(opCtx, nss.db(), MODE_X); mongo::WriteUnitOfWork wuow(opCtx); - auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, nss.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, nss.db()); ASSERT_TRUE(db); db->dropCollection(opCtx, nss.ns()).transitional_ignore(); auto coll = db->createCollection(opCtx, nss.ns(), options); diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 06207b3d3ae..cc060b1f82c 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -847,7 +847,8 @@ void rollbackRenameCollection(OperationContext* opCtx, UUID uuid, RenameCollecti log() << "Attempting to rename collection with UUID: " << uuid << ", from: " << info.renameFrom << ", to: " << info.renameTo; Lock::DBLock dbLock(opCtx, dbName, MODE_X); - auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, dbName); invariant(db); auto status = renameCollectionForRollback(opCtx, info.renameTo, uuid); @@ -1144,7 +1145,8 @@ void rollback_internal::syncFixUp(OperationContext* opCtx, Lock::DBLock dbLock(opCtx, nss.db(), MODE_X); - auto db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, nss.db().toString()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, nss.db().toString()); invariant(db); Collection* collection = UUIDCatalog::get(opCtx).lookupCollectionByUUID(uuid); diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index 51f266dfcf5..0a4de833850 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -349,7 +349,8 @@ int _testRollbackDelete(OperationContext* opCtx, Lock::DBLock dbLock(opCtx, "test", MODE_S); Lock::CollectionLock collLock(opCtx->lockState(), "test.t", MODE_S); - auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, "test"); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, "test"); ASSERT_TRUE(db); auto collection = db->getCollection(opCtx, "test.t"); if (!collection) { @@ -372,7 +373,8 @@ TEST_F(RSRollbackTest, RollbackDeleteDocCmdCollectionAtSourceDropped) { createOplog(_opCtx.get()); { Lock::DBLock dbLock(_opCtx.get(), nss.db(), MODE_X); - auto db = DatabaseHolder::getDatabaseHolder().openDb(_opCtx.get(), nss.db()); + auto databaseHolder = DatabaseHolder::get(_opCtx.get()); + auto db = databaseHolder->openDb(_opCtx.get(), nss.db()); ASSERT_TRUE(db); } ASSERT_EQUALS(-1, @@ -1786,7 +1788,8 @@ TEST_F(RSRollbackTest, RollbackCreateCollectionCommand) { _replicationProcess.get())); { Lock::DBLock dbLock(_opCtx.get(), "test", MODE_S); - auto db = DatabaseHolder::getDatabaseHolder().get(_opCtx.get(), "test"); + auto databaseHolder = DatabaseHolder::get(_opCtx.get()); + auto db = databaseHolder->getDb(_opCtx.get(), "test"); ASSERT_TRUE(db); ASSERT_FALSE(db->getCollection(_opCtx.get(), "test.t")); } diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index cffc5e835f3..6c4c1adbc57 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -381,7 +381,7 @@ Status StorageInterfaceImpl::dropReplicatedDatabases(OperationContext* opCtx) { ReplicationCoordinator::get(opCtx)->dropAllSnapshots(); - auto dbHolder = &DatabaseHolder::getDatabaseHolder(); + auto databaseHolder = DatabaseHolder::get(opCtx); auto hasLocalDatabase = false; for (const auto& dbName : dbNames) { if (dbName == "local") { @@ -389,8 +389,8 @@ Status StorageInterfaceImpl::dropReplicatedDatabases(OperationContext* opCtx) { continue; } writeConflictRetry(opCtx, "dropReplicatedDatabases", dbName, [&] { - if (auto db = dbHolder->get(opCtx, dbName)) { - dbHolder->dropDb(opCtx, db); + if (auto db = databaseHolder->getDb(opCtx, dbName)) { + databaseHolder->dropDb(opCtx, db); } else { // This is needed since dropDatabase can't be rolled back. // This is safe be replaced by "invariant(db);dropDatabase(opCtx, db);" once fixed. diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index 0e1eb7571c9..e6730e59f3b 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -524,7 +524,8 @@ private: CollectionProperties collProperties; Lock::DBLock dbLock(opCtx, nsToDatabaseSubstring(ns), MODE_IS); - auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, ns); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, ns); if (!db) { return collProperties; } diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp index 1a0f2aae759..989f9220896 100644 --- a/src/mongo/db/repl/sync_tail_test.cpp +++ b/src/mongo/db/repl/sync_tail_test.cpp @@ -207,7 +207,8 @@ auto createCollectionWithUuid(OperationContext* opCtx, const NamespaceString& ns void createDatabase(OperationContext* opCtx, StringData dbName) { Lock::GlobalWrite globalLock(opCtx); bool justCreated; - Database* db = DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbName, &justCreated); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->openDb(opCtx, dbName, &justCreated); ASSERT_TRUE(db); ASSERT_TRUE(justCreated); } @@ -938,8 +939,8 @@ TEST_F(SyncTailTest, MultiSyncApplyIgnoresUpdateOperationIfDocumentIsMissingFrom { Lock::GlobalWrite globalLock(_opCtx.get()); bool justCreated = false; - Database* db = - DatabaseHolder::getDatabaseHolder().openDb(_opCtx.get(), nss.db(), &justCreated); + auto databaseHolder = DatabaseHolder::get(_opCtx.get()); + auto db = databaseHolder->openDb(_opCtx.get(), nss.db(), &justCreated); ASSERT_TRUE(db); ASSERT_TRUE(justCreated); } diff --git a/src/mongo/db/s/implicit_create_collection.cpp b/src/mongo/db/s/implicit_create_collection.cpp index 328a461820d..8ee7b7475eb 100644 --- a/src/mongo/db/s/implicit_create_collection.cpp +++ b/src/mongo/db/s/implicit_create_collection.cpp @@ -95,7 +95,8 @@ public: // Take the DBLock and CollectionLock directly rather than using AutoGetCollection // (which calls AutoGetDb) to avoid doing database and shard version checks. Lock::DBLock dbLock(opCtx, _ns.db(), MODE_IS); - const auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, _ns.db()); + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, _ns.db()); if (db) { Lock::CollectionLock collLock(opCtx->lockState(), _ns.ns(), MODE_IS); if (db->getCollection(opCtx, _ns.ns())) { diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp index 81336bd386b..4fd28b98032 100644 --- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp +++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp @@ -237,11 +237,12 @@ void forceDatabaseRefresh(OperationContext* opCtx, const StringData dbName) { // First, check under a shared lock if another thread already updated the cached version. // This is a best-effort optimization to make as few threads as possible to convoy on the // exclusive lock below. + auto databaseHolder = DatabaseHolder::get(opCtx); { // Take the DBLock directly rather than using AutoGetDb, to prevent a recursive call // into checkDbVersion(). Lock::DBLock dbLock(opCtx, dbName, MODE_IS); - const auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, dbName); + auto db = databaseHolder->getDb(opCtx, dbName); if (!db) { log() << "Database " << dbName << " has been dropped; not caching the refreshed databaseVersion"; @@ -261,7 +262,7 @@ void forceDatabaseRefresh(OperationContext* opCtx, const StringData dbName) { // The cached version is older than the refreshed version; update the cached version. Lock::DBLock dbLock(opCtx, dbName, MODE_X); - const auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, dbName); + auto db = databaseHolder->getDb(opCtx, dbName); if (!db) { log() << "Database " << dbName << " has been dropped; not caching the refreshed databaseVersion"; diff --git a/src/mongo/db/service_context_d_test_fixture.cpp b/src/mongo/db/service_context_d_test_fixture.cpp index 8cc88261648..6021681fa68 100644 --- a/src/mongo/db/service_context_d_test_fixture.cpp +++ b/src/mongo/db/service_context_d_test_fixture.cpp @@ -95,7 +95,8 @@ ServiceContextMongoDTest::~ServiceContextMongoDTest() { { auto opCtx = getClient()->makeOperationContext(); Lock::GlobalLock glk(opCtx.get(), MODE_X); - DatabaseHolder::getDatabaseHolder().closeAll(opCtx.get(), "all databases dropped"); + auto databaseHolder = DatabaseHolder::get(opCtx.get()); + databaseHolder->closeAll(opCtx.get(), "all databases dropped"); } IndexBuildsCoordinator::get(getServiceContext())->shutdown(); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp index 375417f2e40..8b9e3114328 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp @@ -96,7 +96,8 @@ public: // fact that oplog collection is so special, Global IX lock can // make sure the collection exists. Lock::DBLock dbLock(opCtx.get(), _ns.db(), MODE_IX); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx.get(), _ns.db()); + auto databaseHolder = DatabaseHolder::get(opCtx.get()); + auto db = databaseHolder->getDb(opCtx.get(), _ns.db()); if (!db) { LOG(2) << "no local database yet"; return false; diff --git a/src/mongo/db/views/durable_view_catalog.cpp b/src/mongo/db/views/durable_view_catalog.cpp index b03554a7feb..00e77886d15 100644 --- a/src/mongo/db/views/durable_view_catalog.cpp +++ b/src/mongo/db/views/durable_view_catalog.cpp @@ -56,8 +56,8 @@ namespace mongo { void DurableViewCatalog::onExternalChange(OperationContext* opCtx, const NamespaceString& name) { dassert(opCtx->lockState()->isDbLockedForMode(name.db(), MODE_IX)); - Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx, name.db()); - + auto databaseHolder = DatabaseHolder::get(opCtx); + auto db = databaseHolder->getDb(opCtx, name.db()); if (db) { opCtx->recoveryUnit()->onCommit( [db](boost::optional<Timestamp>) { db->getViewCatalog()->invalidate(); }); |