diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-12-09 13:16:54 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-12-09 20:22:59 -0500 |
commit | 326d27c5fb249f9d372cb46fd8b97d725b31553a (patch) | |
tree | 065b6bc2e02a33bde3bff7983799bf4e71946db4 /src/mongo/db | |
parent | 5b44e4b489ef6a8eca4e48d3124665f404cc2c92 (diff) | |
download | mongo-326d27c5fb249f9d372cb46fd8b97d725b31553a.tar.gz |
SERVER-16429 Add ScopedTransaction to AutoGetCollectionForRead and Map-reduce
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/client.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/client.h | 1 | ||||
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 10 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp index 63cb26cb6eb..f7722b7dbec 100644 --- a/src/mongo/db/client.cpp +++ b/src/mongo/db/client.cpp @@ -217,6 +217,7 @@ namespace mongo { AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* txn, const std::string& ns) : _txn(txn), + _transaction(txn, MODE_IS), _db(_txn, nsToDatabaseSubstring(ns), MODE_IS), _collLock(_txn->lockState(), ns, MODE_IS), _coll(NULL) { @@ -227,6 +228,7 @@ namespace mongo { AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* txn, const NamespaceString& nss) : _txn(txn), + _transaction(txn, MODE_IS), _db(_txn, nss.db(), MODE_IS), _collLock(_txn->lockState(), nss.toString(), MODE_IS), _coll(NULL) { diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h index e71180edd52..ff35e4394d1 100644 --- a/src/mongo/db/client.h +++ b/src/mongo/db/client.h @@ -150,6 +150,7 @@ namespace mongo { const Timer _timer; OperationContext* const _txn; + const ScopedTransaction _transaction; const AutoGetDb _db; const Lock::CollectionLock _collLock; diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index d2a24ae5a04..c9755ee3e38 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -1341,7 +1341,7 @@ namespace mongo { const NamespaceString nss(config.ns); // Need lock and context to use it - scoped_ptr<Lock::DBRead> lock(new Lock::DBRead(txn->lockState(), nss.db())); + scoped_ptr<AutoGetDb> scopedAutoDb(new AutoGetDb(txn, nss.db(), MODE_S)); const WhereCallbackReal whereCallback(txn, nss.db()); @@ -1357,7 +1357,7 @@ namespace mongo { } std::auto_ptr<CanonicalQuery> cq(cqRaw); - Database* db = dbHolder().get(txn, nss.db()); + Database* db = scopedAutoDb->getDb(); Collection* coll = state.getCollectionOrUassert(db, config.ns); invariant(coll); @@ -1405,14 +1405,14 @@ namespace mongo { // state and yield inside the reduceAndSpillInMemoryState method, so // it only happens if necessary. exec->saveState(); - lock.reset(); + scopedAutoDb.reset(); state.reduceAndSpillInMemoryStateIfNeeded(); - lock.reset(new Lock::DBRead(txn->lockState(), nss.db())); + scopedAutoDb.reset(new AutoGetDb(txn, nss.db(), MODE_S)); exec->restoreState(txn); // Need to reload the database, in case it was dropped after we // released the lock - db = dbHolder().get(txn, nss.db()); + db = scopedAutoDb->getDb(); if (db == NULL) { // Database was deleted after we freed the lock StringBuilder sb; |