Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SERVER-12931 propagate error from MultiPlanRunner::workAllPlans to ge…

…tNext
  • Loading branch information...
commit 552cce169154293d27c9b782cac8a5dec146ceae 1 parent d8f5f9a
@benety benety authored
View
13 src/mongo/db/query/multi_plan_runner.cpp
@@ -219,7 +219,7 @@ namespace mongo {
// If we haven't picked the best plan yet...
if (NULL == _bestPlan) {
- if (!pickBestPlan(NULL)) {
+ if (!pickBestPlan(NULL, objOut)) {
verify(_failure || _killed);
if (_killed) { return Runner::RUNNER_DEAD; }
if (_failure) { return Runner::RUNNER_ERROR; }
@@ -311,12 +311,12 @@ namespace mongo {
return state;
}
- bool MultiPlanRunner::pickBestPlan(size_t* out) {
+ bool MultiPlanRunner::pickBestPlan(size_t* out, BSONObj* objOut) {
static const int timesEachPlanIsWorked = 100;
// Run each plan some number of times.
for (int i = 0; i < timesEachPlanIsWorked; ++i) {
- bool moreToDo = workAllPlans();
+ bool moreToDo = workAllPlans(objOut);
if (!moreToDo) { break; }
}
@@ -430,7 +430,7 @@ namespace mongo {
return true;
}
- bool MultiPlanRunner::workAllPlans() {
+ bool MultiPlanRunner::workAllPlans(BSONObj* objOut) {
bool planHitEOF = false;
for (size_t i = 0; i < _candidates.size(); ++i) {
@@ -501,6 +501,11 @@ namespace mongo {
candidate.failed = true;
++_failureCount;
+ // Propage most recent seen failure to parent.
+ if (PlanStage::FAILURE == state) {
+ WorkingSetCommon::getStatusMemberObject(*candidate.ws, id, objOut);
+ }
+
if (_failureCount == _candidates.size()) {
_failure = true;
return false;
View
7 src/mongo/db/query/multi_plan_runner.h
@@ -79,10 +79,11 @@ namespace mongo {
* All further calls to getNext(...) will return results from the best plan.
*
* Returns true if a best plan was picked, false if there was an error.
+ * If there was a failure in the underlying plan, *objOut may hold error details.
*
* If out is not-NULL, set *out to the index of the picked plan.
*/
- bool pickBestPlan(size_t* out);
+ bool pickBestPlan(size_t* out, BSONObj* objOut);
virtual void saveState();
virtual bool restoreState();
@@ -107,8 +108,10 @@ namespace mongo {
private:
/**
* Have all our candidate plans do something.
+ * If all our candidate plans fail, *objOut will contain
+ * information on the failure.
*/
- bool workAllPlans();
+ bool workAllPlans(BSONObj* objOut);
void allPlansSaveState();
void allPlansRestoreState();
View
3  src/mongo/dbtests/plan_ranking.cpp
@@ -120,7 +120,8 @@ namespace PlanRankingTests {
// And return a pointer to the best solution. The MPR owns the pointer.
size_t bestPlan = numeric_limits<size_t>::max();
- ASSERT(_mpr->pickBestPlan(&bestPlan));
+ BSONObj unused;
+ ASSERT(_mpr->pickBestPlan(&bestPlan, &unused));
ASSERT_LESS_THAN(bestPlan, solutions.size());
return solutions[bestPlan];
}
View
3  src/mongo/dbtests/query_multi_plan_runner.cpp
@@ -136,7 +136,8 @@ namespace QueryMultiPlanRunner {
// Plan 0 aka the first plan aka the index scan should be the best.
size_t best;
- ASSERT(mpr.pickBestPlan(&best));
+ BSONObj unused;
+ ASSERT(mpr.pickBestPlan(&best, &unused));
ASSERT_EQUALS(size_t(0), best);
// Get all our results out.
Please sign in to comment.
Something went wrong with that request. Please try again.