From c03426c28f007425e0aa7de65e3ca9509624128a Mon Sep 17 00:00:00 2001 From: Henrik Edin Date: Wed, 2 Jun 2021 10:16:35 -0400 Subject: SERVER-57351 listDatabases should use in-memory catalog to find index idents There can be an inconsistency when mixing lookups from Collection metadata and DurableCollection. --- src/mongo/db/storage/storage_engine_impl.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp index ddebc8519fd..ab79ae046d0 100644 --- a/src/mongo/db/storage/storage_engine_impl.cpp +++ b/src/mongo/db/storage/storage_engine_impl.cpp @@ -1245,13 +1245,9 @@ int64_t StorageEngineImpl::sizeOnDiskForDb(OperationContext* opCtx, StringData d catalog::forEachCollectionFromDb(opCtx, dbName, MODE_IS, [&](const CollectionPtr& collection) { size += collection->getRecordStore()->storageSize(opCtx); - std::vector indexNames; - collection->getAllIndexes(&indexNames); - - for (size_t i = 0; i < indexNames.size(); i++) { - std::string ident = - _catalog->getIndexIdent(opCtx, collection->getCatalogId(), indexNames[i]); - size += _engine->getIdentSize(opCtx, ident); + auto it = collection->getIndexCatalog()->getIndexIterator(opCtx, true); + while (it->more()) { + size += _engine->getIdentSize(opCtx, it->next()->getIdent()); } return true; -- cgit v1.2.1