summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2020-09-22 15:46:10 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-25 18:16:11 +0000
commit16b23f3ac57b8bb015088fdb6af1fb5667c47624 (patch)
tree4fa2c4dc9d8140b790a2b8e078052ad849d9d071 /src
parenta33dadd70d5733ae2c7f1432c9c82b34cced1588 (diff)
downloadmongo-16b23f3ac57b8bb015088fdb6af1fb5667c47624.tar.gz
SERVER-34243 Use MODE_IS for listCollections
(cherry picked from commit bb148ced1999ffee8ebc58cb0fbefd784ac51a1f) Conflicts: jstests/core/txns/list_collections_not_blocked_by_txn.js src/mongo/db/commands/list_collections.cpp
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/list_collections.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index 71cccabbdf6..73c9bfa9af9 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -46,6 +46,7 @@
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/list_collections_filter.h"
+#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/cursor_manager.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/queued_data_stage.h"
@@ -150,6 +151,9 @@ BSONObj buildViewBson(const ViewDefinition& view) {
return b.obj();
}
+/**
+ * Return an object describing the collection. Takes a collection lock.
+ */
BSONObj buildCollectionBson(OperationContext* opCtx,
const Collection* collection,
bool includePendingDrops) {
@@ -175,6 +179,7 @@ BSONObj buildCollectionBson(OperationContext* opCtx,
b.append("name", collectionName);
b.append("type", "collection");
+ Lock::CollectionLock clk(opCtx->lockState(), nss.ns(), MODE_IS);
CollectionOptions options = collection->getCatalogEntry()->getCollectionOptions(opCtx);
// While the UUID is stored as a collection option, from the user's perspective it is an
@@ -280,7 +285,7 @@ public:
std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> exec;
BSONArrayBuilder firstBatch;
{
- AutoGetDb autoDb(opCtx, dbname, MODE_S);
+ AutoGetDb autoDb(opCtx, dbname, MODE_IS);
Database* db = autoDb.getDb();