From b7df0530e35a23bc1139f22a84ff4ba8b7688b4a Mon Sep 17 00:00:00 2001 From: Pawel Terlecki Date: Tue, 29 Jan 2019 14:25:20 -0500 Subject: SERVER-38316 Consolidate PlanExecutor::DEAD and PlanExecutor::FAILURE Replaced PlanStage::DEAD with PlanStage::FAILURE. In the subsequent commit, PlanExecutor::DEAD will be taken care of in the next commit --- src/mongo/db/exec/and_hash.cpp | 6 +++--- src/mongo/db/exec/and_sorted.cpp | 2 +- src/mongo/db/exec/cached_plan.cpp | 11 ----------- src/mongo/db/exec/collection_scan.cpp | 2 +- src/mongo/db/exec/count.cpp | 2 +- src/mongo/db/exec/delete.cpp | 1 - src/mongo/db/exec/fetch.cpp | 2 +- src/mongo/db/exec/limit.cpp | 2 +- src/mongo/db/exec/merge_sort.cpp | 2 +- src/mongo/db/exec/or.cpp | 2 +- src/mongo/db/exec/plan_stage.h | 6 ------ src/mongo/db/exec/projection.cpp | 2 +- src/mongo/db/exec/queued_data_stage.cpp | 3 +-- src/mongo/db/exec/skip.cpp | 2 +- src/mongo/db/exec/sort.cpp | 2 +- src/mongo/db/exec/trial_stage.cpp | 1 - 16 files changed, 14 insertions(+), 34 deletions(-) (limited to 'src/mongo/db/exec') diff --git a/src/mongo/db/exec/and_hash.cpp b/src/mongo/db/exec/and_hash.cpp index fdce9a79066..07c531bc105 100644 --- a/src/mongo/db/exec/and_hash.cpp +++ b/src/mongo/db/exec/and_hash.cpp @@ -141,7 +141,7 @@ PlanStage::StageState AndHashStage::doWork(WorkingSetID* out) { // yield. _ws->get(_lookAheadResults[i])->makeObjOwnedIfNeeded(); break; // Stop looking at this child. - } else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) { + } else if (PlanStage::FAILURE == childStatus) { // The stage which produces a failure is responsible for allocating a working // set member with error details. invariant(WorkingSet::INVALID_ID != _lookAheadResults[i]); @@ -280,7 +280,7 @@ PlanStage::StageState AndHashStage::readFirstChild(WorkingSetID* out) { _specificStats.mapAfterChild.push_back(_dataMap.size()); return PlanStage::NEED_TIME; - } else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) { + } else if (PlanStage::FAILURE == childStatus) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); @@ -365,7 +365,7 @@ PlanStage::StageState AndHashStage::hashOtherChildren(WorkingSetID* out) { } return PlanStage::NEED_TIME; - } else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) { + } else if (PlanStage::FAILURE == childStatus) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/and_sorted.cpp b/src/mongo/db/exec/and_sorted.cpp index a9e57bf8ea7..ae16646c6cc 100644 --- a/src/mongo/db/exec/and_sorted.cpp +++ b/src/mongo/db/exec/and_sorted.cpp @@ -209,7 +209,7 @@ PlanStage::StageState AndSortedStage::moveTowardTargetRecordId(WorkingSetID* out _isEOF = true; _ws->free(_targetId); return state; - } else if (PlanStage::FAILURE == state || PlanStage::DEAD == state) { + } else if (PlanStage::FAILURE == state) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/cached_plan.cpp b/src/mongo/db/exec/cached_plan.cpp index 5f348ae3533..ec7d1d3608f 100644 --- a/src/mongo/db/exec/cached_plan.cpp +++ b/src/mongo/db/exec/cached_plan.cpp @@ -148,17 +148,6 @@ Status CachedPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) { const bool shouldCache = false; return replan(yieldPolicy, shouldCache); - } else if (PlanStage::DEAD == state) { - BSONObj statusObj; - invariant(WorkingSet::INVALID_ID != id); - WorkingSetCommon::getStatusMemberObject(*_ws, id, &statusObj); - - LOG(1) << "Execution of cached plan failed: PlanStage died" - << ", query: " << redact(_canonicalQuery->toStringShort()) - << " planSummary: " << Explain::getPlanSummary(child().get()) - << " status: " << redact(statusObj); - - return WorkingSetCommon::getMemberObjectStatus(statusObj); } else { invariant(PlanStage::NEED_TIME == state); } diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp index f507a24dba4..b789a39f442 100644 --- a/src/mongo/db/exec/collection_scan.cpp +++ b/src/mongo/db/exec/collection_scan.cpp @@ -122,7 +122,7 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) { << "Last seen record id: " << _lastSeenId); *out = WorkingSetCommon::allocateStatusMember(_workingSet, status); - return PlanStage::DEAD; + return PlanStage::FAILURE; } } diff --git a/src/mongo/db/exec/count.cpp b/src/mongo/db/exec/count.cpp index 15d6ec5baff..3440e843780 100644 --- a/src/mongo/db/exec/count.cpp +++ b/src/mongo/db/exec/count.cpp @@ -82,7 +82,7 @@ PlanStage::StageState CountStage::doWork(WorkingSetID* out) { if (PlanStage::IS_EOF == state) { _commonStats.isEOF = true; return PlanStage::IS_EOF; - } else if (PlanStage::FAILURE == state || PlanStage::DEAD == state) { + } else if (PlanStage::FAILURE == state) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp index e71ec2adcaf..d59a16be27d 100644 --- a/src/mongo/db/exec/delete.cpp +++ b/src/mongo/db/exec/delete.cpp @@ -126,7 +126,6 @@ PlanStage::StageState DeleteStage::doWork(WorkingSetID* out) { break; case PlanStage::FAILURE: - case PlanStage::DEAD: // The stage which produces a failure is responsible for allocating a working set // member with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/fetch.cpp b/src/mongo/db/exec/fetch.cpp index 1a41badc768..eccdd920abe 100644 --- a/src/mongo/db/exec/fetch.cpp +++ b/src/mongo/db/exec/fetch.cpp @@ -119,7 +119,7 @@ PlanStage::StageState FetchStage::doWork(WorkingSetID* out) { } return returnIfMatches(member, id, out); - } else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) { + } else if (PlanStage::FAILURE == status) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/limit.cpp b/src/mongo/db/exec/limit.cpp index 2f1466752f0..506b99bba2d 100644 --- a/src/mongo/db/exec/limit.cpp +++ b/src/mongo/db/exec/limit.cpp @@ -68,7 +68,7 @@ PlanStage::StageState LimitStage::doWork(WorkingSetID* out) { if (PlanStage::ADVANCED == status) { *out = id; --_numToReturn; - } else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) { + } else if (PlanStage::FAILURE == status) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/merge_sort.cpp b/src/mongo/db/exec/merge_sort.cpp index 79c37bb9449..9e1f3877d9e 100644 --- a/src/mongo/db/exec/merge_sort.cpp +++ b/src/mongo/db/exec/merge_sort.cpp @@ -131,7 +131,7 @@ PlanStage::StageState MergeSortStage::doWork(WorkingSetID* out) { // anymore. _noResultToMerge.pop(); return PlanStage::NEED_TIME; - } else if (PlanStage::FAILURE == code || PlanStage::DEAD == code) { + } else if (PlanStage::FAILURE == code) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/or.cpp b/src/mongo/db/exec/or.cpp index d98ae0228fd..cd837084f59 100644 --- a/src/mongo/db/exec/or.cpp +++ b/src/mongo/db/exec/or.cpp @@ -108,7 +108,7 @@ PlanStage::StageState OrStage::doWork(WorkingSetID* out) { } else { return PlanStage::NEED_TIME; } - } else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) { + } else if (PlanStage::FAILURE == childStatus) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/plan_stage.h b/src/mongo/db/exec/plan_stage.h index 7aa5f725f85..37e8d471780 100644 --- a/src/mongo/db/exec/plan_stage.h +++ b/src/mongo/db/exec/plan_stage.h @@ -163,10 +163,6 @@ public: // on the WSM that the held WSID refers to. NEED_YIELD, - // Something went wrong but it's not an internal error. Perhaps our collection was - // dropped or state deleted. - DEAD, - // Something has gone unrecoverably wrong. Stop running this query. // If the out parameter does not refer to an invalid working set member, // call WorkingSetCommon::getStatusMemberObject() to get details on the failure. @@ -184,8 +180,6 @@ public: return "NEED_TIME"; } else if (NEED_YIELD == state) { return "NEED_YIELD"; - } else if (DEAD == state) { - return "DEAD"; } else { verify(FAILURE == state); return "FAILURE"; diff --git a/src/mongo/db/exec/projection.cpp b/src/mongo/db/exec/projection.cpp index 0a559fb2a1c..38b32564798 100644 --- a/src/mongo/db/exec/projection.cpp +++ b/src/mongo/db/exec/projection.cpp @@ -170,7 +170,7 @@ PlanStage::StageState ProjectionStage::doWork(WorkingSetID* out) { } *out = id; - } else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) { + } else if (PlanStage::FAILURE == status) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/queued_data_stage.cpp b/src/mongo/db/exec/queued_data_stage.cpp index 86fba94a4fb..30b07c51af4 100644 --- a/src/mongo/db/exec/queued_data_stage.cpp +++ b/src/mongo/db/exec/queued_data_stage.cpp @@ -58,9 +58,8 @@ PlanStage::StageState QueuedDataStage::doWork(WorkingSetID* out) { *out = _members.front(); _members.pop(); break; - case PlanStage::DEAD: case PlanStage::FAILURE: - // On DEAD or FAILURE, this stage is reponsible for allocating the WorkingSetMember with + // On FAILURE, this stage is reponsible for allocating the WorkingSetMember with // the error details. *out = WorkingSetCommon::allocateStatusMember( _ws, Status(ErrorCodes::InternalError, "Queued data stage failure")); diff --git a/src/mongo/db/exec/skip.cpp b/src/mongo/db/exec/skip.cpp index f17fdee7b81..f2c38003098 100644 --- a/src/mongo/db/exec/skip.cpp +++ b/src/mongo/db/exec/skip.cpp @@ -69,7 +69,7 @@ PlanStage::StageState SkipStage::doWork(WorkingSetID* out) { *out = id; return PlanStage::ADVANCED; - } else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) { + } else if (PlanStage::FAILURE == status) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/sort.cpp b/src/mongo/db/exec/sort.cpp index 918f2a873a1..6ddf5b4078e 100644 --- a/src/mongo/db/exec/sort.cpp +++ b/src/mongo/db/exec/sort.cpp @@ -151,7 +151,7 @@ PlanStage::StageState SortStage::doWork(WorkingSetID* out) { _resultIterator = _data.begin(); _sorted = true; return PlanStage::NEED_TIME; - } else if (PlanStage::FAILURE == code || PlanStage::DEAD == code) { + } else if (PlanStage::FAILURE == code) { // The stage which produces a failure is responsible for allocating a working set member // with error details. invariant(WorkingSet::INVALID_ID != id); diff --git a/src/mongo/db/exec/trial_stage.cpp b/src/mongo/db/exec/trial_stage.cpp index 8053fd636df..a126d5c2bc7 100644 --- a/src/mongo/db/exec/trial_stage.cpp +++ b/src/mongo/db/exec/trial_stage.cpp @@ -142,7 +142,6 @@ PlanStage::StageState TrialStage::_workTrialPlan(WorkingSetID* out) { _replaceCurrentPlan(_queuedData); return NEED_TIME; case PlanStage::FAILURE: - case PlanStage::DEAD: // Either of these cause us to immediately end the trial phase and switch to the backup. BSONObj statusObj; WorkingSetCommon::getStatusMemberObject(*_ws, *out, &statusObj); -- cgit v1.2.1