summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2021-06-02 10:16:35 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-03 13:06:46 +0000
commitc03426c28f007425e0aa7de65e3ca9509624128a (patch)
treeb871f132ce911ca9891fef8495ee7bc842196655
parent7b30ab1943ecbb48e8bdbc50bf928eab09f619b5 (diff)
downloadmongo-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.cpp10
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;