summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2014-05-19 18:51:17 -0400
committerHari Khalsa <hkhalsa@10gen.com>2014-05-20 10:10:57 -0400
commitb03877b9f4ee3384bcff72a7c06cf537d9a4c1a3 (patch)
treec0b948a9f658bcf5a577340f1a97c7ef3c2fecd2
parent2fdfb48d51a31dedb28d34bde6c3a02c22ced969 (diff)
downloadmongo-b03877b9f4ee3384bcff72a7c06cf537d9a4c1a3.tar.gz
SERVER-13641 put opctx into Runners
-rw-r--r--src/mongo/db/catalog/index_create.cpp2
-rw-r--r--src/mongo/db/commands/mr.cpp6
-rw-r--r--src/mongo/db/commands/parallel_collection_scan.cpp2
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp2
-rw-r--r--src/mongo/db/ops/delete_executor.cpp2
-rw-r--r--src/mongo/db/ops/update.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_cursor.cpp7
-rw-r--r--src/mongo/db/query/eof_runner.cpp2
-rw-r--r--src/mongo/db/query/eof_runner.h2
-rw-r--r--src/mongo/db/query/idhack_runner.cpp2
-rw-r--r--src/mongo/db/query/idhack_runner.h2
-rw-r--r--src/mongo/db/query/internal_runner.cpp2
-rw-r--r--src/mongo/db/query/internal_runner.h2
-rw-r--r--src/mongo/db/query/new_find.cpp2
-rw-r--r--src/mongo/db/query/runner.h3
-rw-r--r--src/mongo/db/query/single_solution_runner.cpp2
-rw-r--r--src/mongo/db/query/single_solution_runner.h2
-rw-r--r--src/mongo/db/query/subplan_runner.cpp4
-rw-r--r--src/mongo/db/query/subplan_runner.h2
-rw-r--r--src/mongo/dbtests/runner_registry.cpp16
-rw-r--r--src/mongo/s/d_migrate.cpp2
21 files changed, 37 insertions, 31 deletions
diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp
index 0243a74891a..a0c2fc30111 100644
--- a/src/mongo/db/catalog/index_create.cpp
+++ b/src/mongo/db/catalog/index_create.cpp
@@ -137,7 +137,7 @@ namespace mongo {
collection->deleteDocument( txn, loc, false, true, &toDelete );
logOp( txn, "d", ns.c_str(), toDelete );
- if (!runner->restoreState()) {
+ if (!runner->restoreState(txn)) {
// Runner got killed somehow. This probably shouldn't happen.
if (runnerEOF) {
// Quote: "We were already at the end. Normal.
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 6c1f2a90a74..ff90e6e4b67 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -880,7 +880,7 @@ namespace mongo {
* After calling this method, the temp collection will be completed.
* If inline, the results will be in the in memory map
*/
- void State::finalReduce( CurOp * op , ProgressMeterHolder& pm ) {
+ void State::finalReduce(CurOp * op , ProgressMeterHolder& pm ) {
if (_jsMode) {
// apply the reduce within JS
@@ -995,7 +995,7 @@ namespace mongo {
prev = o;
all.push_back( o );
- if (!runner->restoreState()) {
+ if (!runner->restoreState(_txn)) {
break;
}
@@ -1376,7 +1376,7 @@ namespace mongo {
// if not inline: dump the in memory map to inc collection, all data is on disk
state.dumpToInc();
// final reduce
- state.finalReduce( op , pm );
+ state.finalReduce(op , pm );
reduceTime += rt.micros();
countsBuilder.appendNumber( "reduce" , state.numReduces() );
timingBuilder.appendNumber("reduceTime", reduceTime / 1000);
diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp
index fa0939fc1f1..061175638cd 100644
--- a/src/mongo/db/commands/parallel_collection_scan.cpp
+++ b/src/mongo/db/commands/parallel_collection_scan.cpp
@@ -90,7 +90,7 @@ namespace mongo {
_iterators[i]->prepareToYield();
}
}
- virtual bool restoreState() {
+ virtual bool restoreState(OperationContext* opCtx) {
for (size_t i = 0; i < _iterators.size(); i++) {
if (!_iterators[i]->recoverFromYield()) {
kill();
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 6967dbe51a6..7c6c303e4fa 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -118,7 +118,7 @@ namespace {
// These are all no-ops for PipelineRunners
virtual void saveState() {}
- virtual bool restoreState() { return true; }
+ virtual bool restoreState(OperationContext* opCtx) { return true; }
virtual const Collection* collection() { return NULL; }
/**
diff --git a/src/mongo/db/ops/delete_executor.cpp b/src/mongo/db/ops/delete_executor.cpp
index f0ea6e36a41..a28d86a9dc8 100644
--- a/src/mongo/db/ops/delete_executor.cpp
+++ b/src/mongo/db/ops/delete_executor.cpp
@@ -147,7 +147,7 @@ namespace mongo {
// saving/restoring state repeatedly?
runner->saveState();
collection->deleteDocument(txn, rloc, false, false, logop ? &toDelete : NULL );
- runner->restoreState();
+ runner->restoreState(txn);
nDeleted++;
diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp
index ba375883e7b..872a1253a35 100644
--- a/src/mongo/db/ops/update.cpp
+++ b/src/mongo/db/ops/update.cpp
@@ -663,7 +663,7 @@ namespace mongo {
// Restore state after modification
uassert(17278,
"Update could not restore runner state after updating a document.",
- runner->restoreState());
+ runner->restoreState(txn));
// Call logOp if requested.
if (request.shouldCallLogOp() && !logObj.isEmpty()) {
diff --git a/src/mongo/db/pipeline/document_source_cursor.cpp b/src/mongo/db/pipeline/document_source_cursor.cpp
index bde1a8f32b2..24bd3b86a61 100644
--- a/src/mongo/db/pipeline/document_source_cursor.cpp
+++ b/src/mongo/db/pipeline/document_source_cursor.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/pipeline/document_source.h"
#include "mongo/db/instance.h"
+#include "mongo/db/operation_context_impl.h"
#include "mongo/db/pipeline/document.h"
#include "mongo/db/query/find_constants.h"
#include "mongo/db/query/type_explain.h"
@@ -80,8 +81,9 @@ namespace mongo {
// so we shouldn't check it again.
Lock::DBRead lk(_ns);
Client::Context ctx(_ns, storageGlobalParams.dbpath, /*doVersion=*/false);
+ OperationContextImpl opCtx; // XXX TODO(MATHIAS)
- _runner->restoreState();
+ _runner->restoreState(&opCtx);
int memUsageBytes = 0;
BSONObj obj;
@@ -201,10 +203,11 @@ namespace {
{
Lock::DBRead lk(_ns);
Client::Context ctx(_ns, storageGlobalParams.dbpath, /*doVersion=*/false);
+ OperationContextImpl opCtx; // XXX TODO(MATHIAS)
massert(17392, "No _runner. Were we disposed before explained?",
_runner);
- _runner->restoreState();
+ _runner->restoreState(&opCtx);
TypeExplain* explainRaw;
explainStatus = _runner->getInfo(&explainRaw, NULL);
diff --git a/src/mongo/db/query/eof_runner.cpp b/src/mongo/db/query/eof_runner.cpp
index 3021a4a9004..1438ccd5b6b 100644
--- a/src/mongo/db/query/eof_runner.cpp
+++ b/src/mongo/db/query/eof_runner.cpp
@@ -52,7 +52,7 @@ namespace mongo {
void EOFRunner::saveState() {
}
- bool EOFRunner::restoreState() {
+ bool EOFRunner::restoreState(OperationContext* opCtx) {
// TODO: Does this value matter?
return false;
}
diff --git a/src/mongo/db/query/eof_runner.h b/src/mongo/db/query/eof_runner.h
index cd9e02b8702..983c4b206a7 100644
--- a/src/mongo/db/query/eof_runner.h
+++ b/src/mongo/db/query/eof_runner.h
@@ -60,7 +60,7 @@ namespace mongo {
virtual void saveState();
- virtual bool restoreState();
+ virtual bool restoreState(OperationContext* opCtx);
virtual void invalidate(const DiskLoc& dl, InvalidationType type);
diff --git a/src/mongo/db/query/idhack_runner.cpp b/src/mongo/db/query/idhack_runner.cpp
index 0405f2caf74..ca9124afaae 100644
--- a/src/mongo/db/query/idhack_runner.cpp
+++ b/src/mongo/db/query/idhack_runner.cpp
@@ -186,7 +186,7 @@ namespace mongo {
void IDHackRunner::saveState() { }
- bool IDHackRunner::restoreState() { return true; }
+ bool IDHackRunner::restoreState(OperationContext* opCtx) { return true; }
// Nothing to do here, holding no state.
void IDHackRunner::invalidate(const DiskLoc& dl, InvalidationType type) {
diff --git a/src/mongo/db/query/idhack_runner.h b/src/mongo/db/query/idhack_runner.h
index 1b2b4de95f4..dd2027e19bb 100644
--- a/src/mongo/db/query/idhack_runner.h
+++ b/src/mongo/db/query/idhack_runner.h
@@ -63,7 +63,7 @@ namespace mongo {
virtual void saveState();
- virtual bool restoreState();
+ virtual bool restoreState(OperationContext* opCtx);
virtual void invalidate(const DiskLoc& dl, InvalidationType type);
diff --git a/src/mongo/db/query/internal_runner.cpp b/src/mongo/db/query/internal_runner.cpp
index fa60b334df3..f68b82c5080 100644
--- a/src/mongo/db/query/internal_runner.cpp
+++ b/src/mongo/db/query/internal_runner.cpp
@@ -66,7 +66,7 @@ namespace mongo {
_exec->saveState();
}
- bool InternalRunner::restoreState() {
+ bool InternalRunner::restoreState(OperationContext* opCtx) {
return _exec->restoreState();
}
diff --git a/src/mongo/db/query/internal_runner.h b/src/mongo/db/query/internal_runner.h
index 5b7c7613022..d6af5e43db2 100644
--- a/src/mongo/db/query/internal_runner.h
+++ b/src/mongo/db/query/internal_runner.h
@@ -68,7 +68,7 @@ namespace mongo {
virtual void saveState();
- virtual bool restoreState();
+ virtual bool restoreState(OperationContext* opCtx);
virtual const std::string& ns();
diff --git a/src/mongo/db/query/new_find.cpp b/src/mongo/db/query/new_find.cpp
index ce892370ac3..421791859b5 100644
--- a/src/mongo/db/query/new_find.cpp
+++ b/src/mongo/db/query/new_find.cpp
@@ -222,7 +222,7 @@ namespace mongo {
const int queryOptions = cc->queryOptions();
// Get results out of the runner.
- runner->restoreState();
+ runner->restoreState(txn);
BSONObj obj;
Runner::RunnerState state;
diff --git a/src/mongo/db/query/runner.h b/src/mongo/db/query/runner.h
index ebcc12f82a4..9d915f4f8ae 100644
--- a/src/mongo/db/query/runner.h
+++ b/src/mongo/db/query/runner.h
@@ -35,6 +35,7 @@
namespace mongo {
class Collection;
+ class OperationContext;
class DiskLoc;
class TypeExplain;
struct PlanInfo;
@@ -149,7 +150,7 @@ namespace mongo {
* Restore saved state, possibly after a yield. Return true if the runner is OK, false if
* it was killed.
*/
- virtual bool restoreState() = 0;
+ virtual bool restoreState(OperationContext* opCtx) = 0;
/**
* Return the NS that the query is running over.
diff --git a/src/mongo/db/query/single_solution_runner.cpp b/src/mongo/db/query/single_solution_runner.cpp
index f6566a5000b..a2f4327ccc1 100644
--- a/src/mongo/db/query/single_solution_runner.cpp
+++ b/src/mongo/db/query/single_solution_runner.cpp
@@ -68,7 +68,7 @@ namespace mongo {
_exec->saveState();
}
- bool SingleSolutionRunner::restoreState() {
+ bool SingleSolutionRunner::restoreState(OperationContext* opCtx) {
return _exec->restoreState();
}
diff --git a/src/mongo/db/query/single_solution_runner.h b/src/mongo/db/query/single_solution_runner.h
index bdd697538b4..116faa51000 100644
--- a/src/mongo/db/query/single_solution_runner.h
+++ b/src/mongo/db/query/single_solution_runner.h
@@ -65,7 +65,7 @@ namespace mongo {
virtual void saveState();
- virtual bool restoreState();
+ virtual bool restoreState(OperationContext* opCtx);
virtual void invalidate(const DiskLoc& dl, InvalidationType type);
diff --git a/src/mongo/db/query/subplan_runner.cpp b/src/mongo/db/query/subplan_runner.cpp
index f6400ddd684..765bd236a90 100644
--- a/src/mongo/db/query/subplan_runner.cpp
+++ b/src/mongo/db/query/subplan_runner.cpp
@@ -451,7 +451,7 @@ namespace mongo {
}
}
- bool SubplanRunner::restoreState() {
+ bool SubplanRunner::restoreState(OperationContext* opCtx) {
if (_killed) {
return false;
}
@@ -459,7 +459,7 @@ namespace mongo {
// We're ranking a sub-plan via an MPR or we're streaming results from this Runner. Either
// way, pass on the request.
if (NULL != _underlyingRunner.get()) {
- return _underlyingRunner->restoreState();
+ return _underlyingRunner->restoreState(opCtx);
}
return true;
diff --git a/src/mongo/db/query/subplan_runner.h b/src/mongo/db/query/subplan_runner.h
index 3cefb07d8be..907fe719363 100644
--- a/src/mongo/db/query/subplan_runner.h
+++ b/src/mongo/db/query/subplan_runner.h
@@ -68,7 +68,7 @@ namespace mongo {
virtual void saveState();
- virtual bool restoreState();
+ virtual bool restoreState(OperationContext* opCtx);
virtual void invalidate(const DiskLoc& dl, InvalidationType type);
diff --git a/src/mongo/dbtests/runner_registry.cpp b/src/mongo/dbtests/runner_registry.cpp
index 7071aafb3b0..8881ff2d4f3 100644
--- a/src/mongo/dbtests/runner_registry.cpp
+++ b/src/mongo/dbtests/runner_registry.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
+#include "mongo/db/operation_context_impl.h"
#include "mongo/db/pdfile.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/query/single_solution_runner.h"
@@ -95,6 +96,7 @@ namespace RunnerRegistry {
static const char* ns() { return "unittests.RunnerRegistryDiskLocInvalidation"; }
static DBDirectClient _client;
auto_ptr<Client::WriteContext> _ctx;
+ OperationContextImpl _opCtx;
};
DBDirectClient RunnerRegistryBase::_client;
@@ -128,7 +130,7 @@ namespace RunnerRegistry {
deregisterRunner(run.get());
// And clean up anything that happened before.
- run->restoreState();
+ run->restoreState(&_opCtx);
// Make sure that the runner moved forward over the deleted data. We don't see foo==10
// or foo==11.
@@ -163,7 +165,7 @@ namespace RunnerRegistry {
// Unregister and restore state.
deregisterRunner(run.get());
- run->restoreState();
+ run->restoreState(&_opCtx);
ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL));
ASSERT_EQUALS(10, obj["foo"].numberInt());
@@ -177,7 +179,7 @@ namespace RunnerRegistry {
// Unregister and restore state.
deregisterRunner(run.get());
- run->restoreState();
+ run->restoreState(&_opCtx);
// Runner was killed.
ASSERT_EQUALS(Runner::RUNNER_DEAD, run->getNext(&obj, NULL));
@@ -208,7 +210,7 @@ namespace RunnerRegistry {
// Unregister and restore state.
deregisterRunner(run.get());
- run->restoreState();
+ run->restoreState(&_opCtx);
// Runner was killed.
ASSERT_EQUALS(Runner::RUNNER_DEAD, run->getNext(&obj, NULL));
@@ -239,7 +241,7 @@ namespace RunnerRegistry {
// Unregister and restore state.
deregisterRunner(run.get());
- run->restoreState();
+ run->restoreState(&_opCtx);
// Runner was killed.
ASSERT_EQUALS(Runner::RUNNER_DEAD, run->getNext(&obj, NULL));
@@ -271,7 +273,7 @@ namespace RunnerRegistry {
// Unregister and restore state.
deregisterRunner(run.get());
- run->restoreState();
+ run->restoreState(&_opCtx);
ASSERT_EQUALS(Runner::RUNNER_ADVANCED, run->getNext(&obj, NULL));
ASSERT_EQUALS(10, obj["foo"].numberInt());
@@ -287,7 +289,7 @@ namespace RunnerRegistry {
// Unregister and restore state.
deregisterRunner(run.get());
- run->restoreState();
+ run->restoreState(&_opCtx);
// Runner was killed.
ASSERT_EQUALS(Runner::RUNNER_DEAD, run->getNext(&obj, NULL));
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index 2a666317422..06ff9ccb9db 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/src/mongo/s/d_migrate.cpp
@@ -640,7 +640,7 @@ namespace mongo {
virtual void saveState() {
invariant( false );
}
- virtual bool restoreState() {
+ virtual bool restoreState(OperationContext* opCtx) {
invariant( false );
}
virtual const string& ns() {