summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/query/multi_plan_runner.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/db/query/multi_plan_runner.cpp b/src/mongo/db/query/multi_plan_runner.cpp
index d99ad25cd85..4547b92e3e2 100644
--- a/src/mongo/db/query/multi_plan_runner.cpp
+++ b/src/mongo/db/query/multi_plan_runner.cpp
@@ -127,10 +127,14 @@ namespace mongo {
if (_failure || _killed) { return false; }
if (NULL != _bestPlan) {
- return _bestPlan->restoreState();
+ bool best = _bestPlan->restoreState();
+ // backup plan is OK by default. Only can be set to not-OK if it exists and fails.
+ bool backup = true;
if (NULL != _backupPlan) {
- _backupPlan->restoreState();
+ backup = _backupPlan->restoreState();
}
+ // We're OK to continue if the best plan and the backup plan are OK.
+ return best && backup;
}
else {
allPlansRestoreState();
@@ -215,6 +219,7 @@ namespace mongo {
_killed = true;
_collection = NULL;
if (NULL != _bestPlan) { _bestPlan->kill(); }
+ if (NULL != _backupPlan) { _backupPlan->kill(); }
}
Runner::RunnerState MultiPlanRunner::getNext(BSONObj* objOut, DiskLoc* dlOut) {
@@ -295,11 +300,14 @@ namespace mongo {
PlanCache* cache = collection->infoCache()->getPlanCache();
cache->remove(*_query);
+ // Move the backup info into the bestPlan info and clear the backup
+ // info.
_bestPlan.reset(_backupPlan);
_backupPlan = NULL;
_bestSolution.reset(_backupSolution);
_backupSolution = NULL;
_alreadyProduced = _backupAlreadyProduced;
+ _backupAlreadyProduced.clear();
return getNext(objOut, dlOut);
}