diff options
author | Sophia Tan <sophia_tll@hotmail.com> | 2022-01-28 17:25:40 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-28 18:04:56 +0000 |
commit | 1b18cd9b5dcb352c6fdd6b15d4bd0a40c0da35c3 (patch) | |
tree | 8f772962b2c8f4ac9e066cefc63a78f2e97c7808 /src/mongo/db/startup_recovery.cpp | |
parent | 50caf49d16f8245856211db493d983acc864fa6d (diff) | |
download | mongo-1b18cd9b5dcb352c6fdd6b15d4bd0a40c0da35c3.tar.gz |
SERVER-63058 Change StorageEngineImpl::listDatabases() to return a list of TenantDatabaseName instead of string
Diffstat (limited to 'src/mongo/db/startup_recovery.cpp')
-rw-r--r-- | src/mongo/db/startup_recovery.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mongo/db/startup_recovery.cpp b/src/mongo/db/startup_recovery.cpp index 179d4f35be3..0c2aed85986 100644 --- a/src/mongo/db/startup_recovery.cpp +++ b/src/mongo/db/startup_recovery.cpp @@ -257,10 +257,10 @@ void openDatabases(OperationContext* opCtx, const StorageEngine* storageEngine, invariant(opCtx->lockState()->isW()); auto databaseHolder = DatabaseHolder::get(opCtx); - auto dbNames = storageEngine->listDatabases(); - for (const auto& dbName : dbNames) { - LOGV2_DEBUG(21010, 1, " Opening database: {dbName}", "dbName"_attr = dbName); - auto db = databaseHolder->openDb(opCtx, dbName); + auto tenantDbNames = storageEngine->listDatabases(); + for (const auto& tenantDbName : tenantDbNames) { + LOGV2_DEBUG(21010, 1, " Opening database: {dbName}", "dbName"_attr = tenantDbName); + auto db = databaseHolder->openDb(opCtx, tenantDbName.dbName()); invariant(db); onDatabase(db); @@ -482,19 +482,21 @@ void startupRepair(OperationContext* opCtx, StorageEngine* storageEngine) { // The local database should be repaired before any other replicated collections so we know // whether not to rebuild unfinished two-phase index builds if this is a replica set node // running in standalone mode. - auto dbNames = storageEngine->listDatabases(); - if (auto it = std::find(dbNames.begin(), dbNames.end(), NamespaceString::kLocalDb); - it != dbNames.end()) { - fassertNoTrace(4805001, repair::repairDatabase(opCtx, storageEngine, *it)); + auto tenantDbNames = storageEngine->listDatabases(); + if (auto it = std::find(tenantDbNames.begin(), + tenantDbNames.end(), + TenantDatabaseName(boost::none, NamespaceString::kLocalDb)); + it != tenantDbNames.end()) { + fassertNoTrace(4805001, repair::repairDatabase(opCtx, storageEngine, it->dbName())); // This must be set before rebuilding index builds on replicated collections. setReplSetMemberInStandaloneMode(opCtx, StartupRecoveryMode::kAuto); - dbNames.erase(it); + tenantDbNames.erase(it); } // Repair the remaining databases. - for (const auto& dbName : dbNames) { - fassertNoTrace(18506, repair::repairDatabase(opCtx, storageEngine, dbName)); + for (const auto& tenantDbName : tenantDbNames) { + fassertNoTrace(18506, repair::repairDatabase(opCtx, storageEngine, tenantDbName.dbName())); } openDatabases(opCtx, storageEngine, [&](auto db) { |