diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2021-06-02 10:16:35 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-03 13:06:46 +0000 |
commit | c03426c28f007425e0aa7de65e3ca9509624128a (patch) | |
tree | b871f132ce911ca9891fef8495ee7bc842196655 | |
parent | 7b30ab1943ecbb48e8bdbc50bf928eab09f619b5 (diff) | |
download | mongo-SERVER-57348.tar.gz |
SERVER-57351 listDatabases should use in-memory catalog to find index identsSERVER-57348
There can be an inconsistency when mixing lookups from Collection metadata and DurableCollection.
-rw-r--r-- | src/mongo/db/storage/storage_engine_impl.cpp | 10 |
1 files 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<std::string> 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; |