diff options
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/find_cmd.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/commands/list_indexes.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/commands/parallel_collection_scan.cpp | 3 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index fe1d0940ff9..cbe0ce20d55 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -40,6 +40,7 @@ #include "mongo/db/clientcursor.h" #include "mongo/db/commands.h" #include "mongo/db/commands/run_aggregate.h" +#include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/db_raii.h" #include "mongo/db/exec/working_set_common.h" #include "mongo/db/matcher/extensions_callback_real.h" @@ -228,14 +229,14 @@ public: const std::string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNsOrUUID(opCtx, dbname, cmdObj)); - // Although it is a command, a find command gets counted as a query. globalOpCounters.gotQuery(); // Parse the command BSON to a QueryRequest. const bool isExplain = false; - auto qrStatus = QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain); + // Pass parseNs to makeFromFindCommand in case cmdObj does not have a UUID. + auto qrStatus = QueryRequest::makeFromFindCommand( + NamespaceString(parseNs(dbname, cmdObj)), cmdObj, isExplain); if (!qrStatus.isOK()) { return appendCommandStatus(result, qrStatus.getStatus()); } @@ -252,6 +253,12 @@ public: } } + // Acquire locks. If the query is on a view, we release our locks and convert the query + // request into an aggregation command. + Lock::DBLock dbSLock(opCtx, dbname, MODE_IS); + const NamespaceString nss(parseNsOrUUID(opCtx, dbname, cmdObj)); + qr->refreshNSS(opCtx); + // Fill out curop information. // // We pass negative values for 'ntoreturn' and 'ntoskip' to indicate that these values @@ -276,9 +283,7 @@ public: } std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue()); - // Acquire locks. If the query is on a view, we release our locks and convert the query - // request into an aggregation command. - AutoGetCollectionOrViewForReadCommand ctx(opCtx, nss); + AutoGetCollectionOrViewForReadCommand ctx(opCtx, nss, std::move(dbSLock)); Collection* collection = ctx.getCollection(); if (ctx.getView()) { // Relinquish locks. The aggregation command will re-acquire them. diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index a050e9adfff..74b75cfeffa 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -120,6 +120,7 @@ public: const string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) { + Lock::DBLock dbSLock(opCtx, dbname, MODE_IS); const NamespaceString ns(parseNsOrUUID(opCtx, dbname, cmdObj)); const long long defaultBatchSize = std::numeric_limits<long long>::max(); long long batchSize; @@ -129,7 +130,7 @@ public: return appendCommandStatus(result, parseCursorStatus); } - AutoGetCollectionForReadCommand autoColl(opCtx, ns); + AutoGetCollectionForReadCommand autoColl(opCtx, ns, std::move(dbSLock)); if (!autoColl.getDb()) { return appendCommandStatus( result, diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp index 5fbe37b1132..6b84996369c 100644 --- a/src/mongo/db/commands/parallel_collection_scan.cpp +++ b/src/mongo/db/commands/parallel_collection_scan.cpp @@ -89,9 +89,10 @@ public: const string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) { + Lock::DBLock dbSLock(opCtx, dbname, MODE_IS); const NamespaceString ns(parseNsOrUUID(opCtx, dbname, cmdObj)); - AutoGetCollectionForReadCommand ctx(opCtx, ns); + AutoGetCollectionForReadCommand ctx(opCtx, ns, std::move(dbSLock)); Collection* collection = ctx.getCollection(); if (!collection) |