diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-09-26 14:02:49 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-10-06 17:30:12 -0400 |
commit | 101e026f45dea5e9e68520238495c89a476e6172 (patch) | |
tree | bbdd3710ffc5721527ad9f5682ef0dbb4876dfee /src/mongo/db/commands/index_filter_commands.cpp | |
parent | 10c86dc6cad9853514148e0ab59894a0d29353b9 (diff) | |
download | mongo-101e026f45dea5e9e68520238495c89a476e6172.tar.gz |
SERVER-14668/SERVER-15294 Collection-level locking for all read paths
Diffstat (limited to 'src/mongo/db/commands/index_filter_commands.cpp')
-rw-r--r-- | src/mongo/db/commands/index_filter_commands.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp index ab47fe40fe7..a876a0a509a 100644 --- a/src/mongo/db/commands/index_filter_commands.cpp +++ b/src/mongo/db/commands/index_filter_commands.cpp @@ -169,11 +169,12 @@ namespace mongo { BSONObj& cmdObj, BSONObjBuilder* bob) { // This is a read lock. The query settings is owned by the collection. - Client::ReadContext ctx(txn, ns); - Collection* collection = ctx.ctx().db()->getCollection(txn, ns); + AutoGetCollectionForRead ctx(txn, ns); + QuerySettings* querySettings; PlanCache* unused; - Status status = getQuerySettingsAndPlanCache(txn, collection, ns, &querySettings, &unused); + Status status = + getQuerySettingsAndPlanCache(txn, ctx.getCollection(), ns, &querySettings, &unused); if (!status.isOK()) { // No collection - return empty array of filters. BSONArrayBuilder hintsBuilder(bob->subarrayStart("filters")); @@ -231,12 +232,12 @@ namespace mongo { BSONObj& cmdObj, BSONObjBuilder* bob) { // This is a read lock. The query settings is owned by the collection. - Client::ReadContext ctx(txn, ns); - Collection* collection = ctx.ctx().db()->getCollection(txn, ns); + AutoGetCollectionForRead ctx(txn, ns); + QuerySettings* querySettings; PlanCache* planCache; Status status = - getQuerySettingsAndPlanCache(txn, collection, ns, &querySettings, &planCache); + getQuerySettingsAndPlanCache(txn, ctx.getCollection(), ns, &querySettings, &planCache); if (!status.isOK()) { // No collection - do nothing. return Status::OK(); @@ -326,12 +327,13 @@ namespace mongo { BSONObj& cmdObj, BSONObjBuilder* bob) { // This is a read lock. The query settings is owned by the collection. - Client::ReadContext ctx(txn, ns); - Collection* collection = ctx.ctx().db()->getCollection(txn, ns); + const NamespaceString nss(ns); + AutoGetCollectionForRead ctx(txn, nss); + QuerySettings* querySettings; PlanCache* planCache; Status status = - getQuerySettingsAndPlanCache(txn, collection, ns, &querySettings, &planCache); + getQuerySettingsAndPlanCache(txn, ctx.getCollection(), ns, &querySettings, &planCache); if (!status.isOK()) { return status; } |