diff options
| author | Allison Easton <allison.easton@mongodb.com> | 2024-08-14 21:48:35 +0200 |
|---|---|---|
| committer | MongoDB Bot <mongo-bot@mongodb.com> | 2024-08-14 20:38:09 +0000 |
| commit | 1b488fa20bdc54915b89f3a6ef981742adbe8cb2 (patch) | |
| tree | b523d50dc566e2003bdc2d42598df90e41b90db8 | |
| parent | f106ce85d1fb171e45c435db4b24bd18f1d6f3de (diff) | |
Revert "SERVER-92273 ListCollections without filter should include commit pending namespaces (7.0 only)" (#26125)r7.0.14-rc0r7.0.14
GitOrigin-RevId: ce59cfc6a3c5e5c067dca0d30697edd68d4f5188
| -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); } } |
