diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-01-14 10:23:44 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-01-15 10:41:44 -0500 |
commit | 8d5d775b843d7566ca60a087ea17a512f67c3dc9 (patch) | |
tree | 30635cf1d59bbe4ee97bbffd5d3aa2587c7e95b9 /src/mongo/db/commands/mr.cpp | |
parent | 02a78a7f3d936813ea9e4195887b11d83448fcd6 (diff) | |
download | mongo-8d5d775b843d7566ca60a087ea17a512f67c3dc9.tar.gz |
SERVER-16822 Add ScopedTransactions to places which were missing it
Diffstat (limited to 'src/mongo/db/commands/mr.cpp')
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index f6d340b97d3..3a0d2aa048e 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -344,7 +344,7 @@ namespace mongo { if (_useIncremental) { // We don't want to log the deletion of incLong as it isn't replicated. While // harmless, this would lead to a scary looking warning on the secondaries. - ScopedTransaction(_txn, MODE_IX); + ScopedTransaction scopedXact(_txn, MODE_IX); Lock::DBLock lk(_txn->lockState(), nsToDatabaseSubstring(_config.incLong), MODE_X); @@ -611,7 +611,7 @@ namespace mongo { _safeCount(_db, _config.tempNamespace, BSONObj())); auto_ptr<DBClientCursor> cursor = _db.query(_config.tempNamespace , BSONObj()); while (cursor->more()) { - ScopedTransaction(_txn, MODE_IX); + ScopedTransaction scopedXact(_txn, MODE_IX); Lock::DBLock lock(_txn->lockState(), nsToDatabaseSubstring(_config.outputOptions.finalNamespace), MODE_X); @@ -1340,17 +1340,22 @@ namespace mongo { progress.showTotal(showTotal); ProgressMeterHolder pm(progress); - wassert( config.limit < 0x4000000 ); // see case on next line to 32 bit unsigned + // See cast on next line to 32 bit unsigned + wassert(config.limit < 0x4000000); long long mapTime = 0; long long reduceTime = 0; long long numInputs = 0; + { - // We've got a cursor preventing migrations off, now re-establish our useful cursor + // We've got a cursor preventing migrations off, now re-establish our + // useful cursor. const NamespaceString nss(config.ns); // Need lock and context to use it + scoped_ptr<ScopedTransaction> scopedXact( + new ScopedTransaction(txn, MODE_IS)); scoped_ptr<AutoGetDb> scopedAutoDb(new AutoGetDb(txn, nss.db(), MODE_S)); const WhereCallbackReal whereCallback(txn, nss.db()); @@ -1415,9 +1420,15 @@ namespace mongo { // state and yield inside the reduceAndSpillInMemoryState method, so // it only happens if necessary. exec->saveState(); + scopedAutoDb.reset(); + scopedXact.reset(); + state.reduceAndSpillInMemoryStateIfNeeded(); + + scopedXact.reset(new ScopedTransaction(txn, MODE_IS)); scopedAutoDb.reset(new AutoGetDb(txn, nss.db(), MODE_S)); + exec->restoreState(txn); // Need to reload the database, in case it was dropped after we |