diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-04-08 10:46:00 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-04-10 03:45:53 -0400 |
commit | 8cb23dbe2fac05ee28542fc24befc13c222ea006 (patch) | |
tree | 89d46ff18ff1c3aace4b9d190393264da27183e8 /src/mongo/db/repair_database.cpp | |
parent | 28a6425d9e773c3a0d6879f65b4e2ee47c96fd21 (diff) | |
download | mongo-8cb23dbe2fac05ee28542fc24befc13c222ea006.tar.gz |
SERVER-39515 Remove DatabaseCatalogEntry
Diffstat (limited to 'src/mongo/db/repair_database.cpp')
-rw-r--r-- | src/mongo/db/repair_database.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/mongo/db/repair_database.cpp b/src/mongo/db/repair_database.cpp index e375a67d524..4d690411b1b 100644 --- a/src/mongo/db/repair_database.cpp +++ b/src/mongo/db/repair_database.cpp @@ -43,7 +43,6 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog_entry.h" #include "mongo/db/catalog/database.h" -#include "mongo/db/catalog/database_catalog_entry.h" #include "mongo/db/catalog/database_holder.h" #include "mongo/db/catalog/document_validation.h" #include "mongo/db/catalog/index_key_validate.h" @@ -62,7 +61,6 @@ namespace mongo { StatusWith<IndexNameObjs> getIndexNameObjs(OperationContext* opCtx, - DatabaseCatalogEntry* dbce, CollectionCatalogEntry* cce, stdx::function<bool(const std::string&)> filter) { IndexNameObjs ret; @@ -111,7 +109,6 @@ StatusWith<IndexNameObjs> getIndexNameObjs(OperationContext* opCtx, } Status rebuildIndexesOnCollection(OperationContext* opCtx, - DatabaseCatalogEntry* dbce, CollectionCatalogEntry* cce, const std::vector<BSONObj>& indexSpecs) { // Skip the rest if there are no indexes to rebuild. @@ -122,15 +119,14 @@ Status rebuildIndexesOnCollection(OperationContext* opCtx, IndexBuildsCoordinator* indexBuildsCoord = IndexBuildsCoordinator::get(opCtx); UUID buildUUID = UUID::gen(); auto swRebuild = - indexBuildsCoord->startIndexRebuildForRecovery(opCtx, dbce, cce, indexSpecs, buildUUID); + indexBuildsCoord->startIndexRebuildForRecovery(opCtx, cce, indexSpecs, buildUUID); if (!swRebuild.isOK()) { return swRebuild.getStatus(); } auto[numRecords, dataSize] = swRebuild.getValue(); - const auto& ns = cce->ns().ns(); - auto rs = dbce->getRecordStore(ns); + auto rs = cce->getRecordStore(); // Update the record store stats after finishing and committing the index builds. WriteUnitOfWork wuow(opCtx); @@ -146,33 +142,31 @@ Status repairCollections(OperationContext* opCtx, const std::string& dbName, stdx::function<void(const std::string& dbName)> onRecordStoreRepair) { - DatabaseCatalogEntry* dbce = engine->getDatabaseCatalogEntry(opCtx, dbName); + auto colls = UUIDCatalog::get(opCtx).getAllCollectionNamesFromDb(dbName); - std::list<std::string> colls; - dbce->getCollectionNamespaces(&colls); - - for (std::list<std::string>::const_iterator it = colls.begin(); it != colls.end(); ++it) { + for (const auto& nss : colls) { opCtx->checkForInterrupt(); - log() << "Repairing collection " << *it; + log() << "Repairing collection " << nss; - Status status = engine->repairRecordStore(opCtx, *it); + Status status = engine->repairRecordStore(opCtx, nss.ns()); if (!status.isOK()) return status; } onRecordStoreRepair(dbName); - for (std::list<std::string>::const_iterator it = colls.begin(); it != colls.end(); ++it) { + for (const auto& nss : colls) { opCtx->checkForInterrupt(); - CollectionCatalogEntry* cce = dbce->getCollectionCatalogEntry(*it); - auto swIndexNameObjs = getIndexNameObjs(opCtx, dbce, cce); + CollectionCatalogEntry* cce = + UUIDCatalog::get(opCtx).lookupCollectionCatalogEntryByNamespace(nss); + auto swIndexNameObjs = getIndexNameObjs(opCtx, cce); if (!swIndexNameObjs.isOK()) return swIndexNameObjs.getStatus(); std::vector<BSONObj> indexSpecs = swIndexNameObjs.getValue().second; - Status status = rebuildIndexesOnCollection(opCtx, dbce, cce, indexSpecs); + Status status = rebuildIndexesOnCollection(opCtx, cce, indexSpecs); if (!status.isOK()) return status; |