diff options
Diffstat (limited to 'src/mongo/db/exec/multi_plan.h')
-rw-r--r-- | src/mongo/db/exec/multi_plan.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/mongo/db/exec/multi_plan.h b/src/mongo/db/exec/multi_plan.h index 964d71443d0..956969eb2d2 100644 --- a/src/mongo/db/exec/multi_plan.h +++ b/src/mongo/db/exec/multi_plan.h @@ -36,6 +36,7 @@ #include "mongo/db/query/canonical_query.h" #include "mongo/db/query/query_solution.h" #include "mongo/db/query/plan_ranker.h" +#include "mongo/db/query/plan_yield_policy.h" namespace mongo { @@ -81,9 +82,15 @@ namespace mongo { /** * Runs all plans added by addPlan, ranks them, and picks a best. - * All further calls to getNext(...) will return results from the best plan. + * All further calls to work(...) will return results from the best plan. + * + * If 'yieldPolicy' is non-NULL, then all locks may be yielded in between round-robin + * works of the candidate plans. By default, 'yieldPolicy' is NULL and no yielding will + * take place. + * + * Returns a non-OK status if the plan was killed during yield. */ - void pickBestPlan(); + Status pickBestPlan(PlanYieldPolicy* yieldPolicy); /** Return true if a best plan has been chosen */ bool bestPlanChosen() const; @@ -156,20 +163,24 @@ namespace mongo { // uses -1 / kNoSuchPlan when best plan is not (yet) known int _backupPlanIdx; - // Did all plans fail while we were running them? Note that one plan can fail + // Set if this MultiPlanStage cannot continue, and the query must fail. This can happen in + // two ways. The first is that all candidate plans fail. Note that one plan can fail // during normal execution of the plan competition. Here is an example: // // Plan 1: collection scan with sort. Sort runs out of memory. // Plan 2: ixscan that provides sort. Won't run out of memory. // // We want to choose plan 2 even if plan 1 fails. + // + // The second way for failure to occur is that the execution of this query is killed during + // a yield, by some concurrent event such as a collection drop. bool _failure; // If everything fails during the plan competition, we can't pick one. size_t _failureCount; // if pickBestPlan fails, this is set to the wsid of the statusMember - // returned by ::work() + // returned by ::work() WorkingSetID _statusMemberId; // Stats |