diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mongo/db/commands/list_collections.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp index 77c6b2a7d2f..544e6e222ea 100644 --- a/src/mongo/db/commands/list_collections.cpp +++ b/src/mongo/db/commands/list_collections.cpp @@ -431,10 +431,16 @@ public: return true; }; - std::vector<const Collection*> collections = - catalog->establishConsistentCollections(opCtx, dbName, readTimestamp); - for (const auto& collection : collections) { - perCollectionWork(collection); + // If we are lock-free we can just iterate over our collection catalog + // without needing to yield as we don't take any locks. + if (opCtx->isLockFreeReadsOp()) { + auto collectionCatalog = CollectionCatalog::get(opCtx); + for (auto&& coll : collectionCatalog->range(dbName)) { + perCollectionWork(coll); + } + } else { + mongo::catalog::forEachCollectionFromDb( + opCtx, dbName, MODE_IS, perCollectionWork); } } |
