summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/cached_plan.cpp
diff options
context:
space:
mode:
authorDavid Percy <david.percy@mongodb.com>2020-01-06 19:41:50 +0000
committerevergreen <evergreen@mongodb.com>2020-01-06 19:41:50 +0000
commitd0671dc95e8144d5828343f7431715537945425b (patch)
tree806853e44030ea48a08387653ed3aada2103cb97 /src/mongo/db/exec/cached_plan.cpp
parent7a6ce77cbbad266e86f2b34e580ed163bbf9119b (diff)
downloadmongo-d0671dc95e8144d5828343f7431715537945425b.tar.gz
SERVER-40805 Indicate reason for replanning
Diffstat (limited to 'src/mongo/db/exec/cached_plan.cpp')
-rw-r--r--src/mongo/db/exec/cached_plan.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/db/exec/cached_plan.cpp b/src/mongo/db/exec/cached_plan.cpp
index 9738936f4b7..7f35e28a63d 100644
--- a/src/mongo/db/exec/cached_plan.cpp
+++ b/src/mongo/db/exec/cached_plan.cpp
@@ -147,7 +147,10 @@ Status CachedPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
<< " status: " << redact(statusObj);
const bool shouldCache = false;
- return replan(yieldPolicy, shouldCache);
+ return replan(yieldPolicy,
+ shouldCache,
+ str::stream() << "cached plan returned: "
+ << WorkingSetCommon::toStatusString(statusObj));
} else {
invariant(PlanStage::NEED_TIME == state);
}
@@ -162,7 +165,13 @@ Status CachedPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
<< " plan summary before replan: " << Explain::getPlanSummary(child().get());
const bool shouldCache = true;
- return replan(yieldPolicy, shouldCache);
+ return replan(
+ yieldPolicy,
+ shouldCache,
+ str::stream()
+ << "cached plan was less efficient than expected: expected trial execution to take "
+ << _decisionWorks << " works but it took at least " << maxWorksBeforeReplan
+ << " works");
}
Status CachedPlanStage::tryYield(PlanYieldPolicy* yieldPolicy) {
@@ -179,7 +188,7 @@ Status CachedPlanStage::tryYield(PlanYieldPolicy* yieldPolicy) {
return Status::OK();
}
-Status CachedPlanStage::replan(PlanYieldPolicy* yieldPolicy, bool shouldCache) {
+Status CachedPlanStage::replan(PlanYieldPolicy* yieldPolicy, bool shouldCache, std::string reason) {
// We're going to start over with a new plan. Clear out info from our old plan.
{
std::queue<WorkingSetID> emptyQueue;
@@ -188,7 +197,7 @@ Status CachedPlanStage::replan(PlanYieldPolicy* yieldPolicy, bool shouldCache) {
_ws->clear();
_children.clear();
- _specificStats.replanned = true;
+ _specificStats.replanReason = std::move(reason);
if (shouldCache) {
// Deactivate the current cache entry.