summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@10gen.com>2015-04-21 08:50:52 -0400
committerJames Wahlin <james.wahlin@10gen.com>2015-06-09 13:41:37 -0400
commitd690653daadef98652e58131ade8b34114f86ab2 (patch)
treefd38454b9d4bc8d8d64c61334885e40d1644a235 /src/mongo/db/commands
parent6f9285ba8e37aee90acb9069cfe477db626281c2 (diff)
downloadmongo-d690653daadef98652e58131ade8b34114f86ab2.tar.gz
SERVER-2454 Improve PlanExecutor::DEAD handling
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp8
-rw-r--r--src/mongo/db/commands/find_cmd.cpp12
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp13
-rw-r--r--src/mongo/db/commands/group.cpp6
4 files changed, 23 insertions, 16 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index f911d6520fd..88019cbdc3c 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -103,8 +103,12 @@ namespace {
return boost::optional<BSONObj>(std::move(value));
}
if (PlanExecutor::FAILURE == state || PlanExecutor::DEAD == state) {
- if (PlanExecutor::FAILURE == state &&
- WorkingSetCommon::isValidStatusMemberObject(value)) {
+ const std::unique_ptr<PlanStageStats> stats(exec->getStats());
+ error() << "Plan executor error during findAndModify: "
+ << PlanExecutor::statestr(state)
+ << ", stats: " << Explain::statsToBSON(*stats);
+
+ if (WorkingSetCommon::isValidStatusMemberObject(value)) {
const Status errorStatus =
WorkingSetCommon::getMemberObjectStatus(value);
invariant(!errorStatus.isOK());
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 744a8eb88ca..3c8c0fe45ad 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -313,13 +313,17 @@ namespace mongo {
}
// Throw an assertion if query execution fails for any reason.
- if (PlanExecutor::FAILURE == state) {
+ if (PlanExecutor::FAILURE == state || PlanExecutor::DEAD == state) {
const std::unique_ptr<PlanStageStats> stats(exec->getStats());
- error() << "Plan executor error, stats: " << Explain::statsToBSON(*stats);
+ error() << "Plan executor error during find command: "
+ << PlanExecutor::statestr(state)
+ << ", stats: " << Explain::statsToBSON(*stats);
+
return appendCommandStatus(result,
Status(ErrorCodes::OperationFailed,
- str::stream() << "Executor error: "
- << WorkingSetCommon::toStatusString(obj)));
+ str::stream()
+ << "Executor error during find command: "
+ << WorkingSetCommon::toStatusString(obj)));
}
// 6) Set up the cursor for getMore.
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index bc2bf72328e..e075fbd047e 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -368,18 +368,15 @@ namespace mongo {
}
}
- if (PlanExecutor::FAILURE == *state) {
+ if (PlanExecutor::FAILURE == *state || PlanExecutor::DEAD == *state) {
const std::unique_ptr<PlanStageStats> stats(exec->getStats());
- error() << "GetMore executor error, stats: " << Explain::statsToBSON(*stats);
+ error() << "GetMore command executor error: " << PlanExecutor::statestr(*state)
+ << ", stats: " << Explain::statsToBSON(*stats);
+
return Status(ErrorCodes::OperationFailed,
- str::stream() << "GetMore executor error: "
+ str::stream() << "GetMore command executor error: "
<< WorkingSetCommon::toStatusString(obj));
}
- else if (PlanExecutor::DEAD == *state) {
- return Status(ErrorCodes::OperationFailed,
- str::stream() << "Plan executor killed during getMore command, "
- << "ns: " << request.nss.ns());
- }
return Status::OK();
}
diff --git a/src/mongo/db/commands/group.cpp b/src/mongo/db/commands/group.cpp
index 4dd4f5a1956..adfb6fae37f 100644
--- a/src/mongo/db/commands/group.cpp
+++ b/src/mongo/db/commands/group.cpp
@@ -158,8 +158,9 @@ namespace mongo {
BSONObj retval;
PlanExecutor::ExecState state = planExecutor->getNext(&retval, NULL);
if (PlanExecutor::ADVANCED != state) {
- if (PlanExecutor::FAILURE == state &&
- WorkingSetCommon::isValidStatusMemberObject(retval)) {
+ invariant(PlanExecutor::FAILURE == state || PlanExecutor::DEAD == state);
+
+ if (WorkingSetCommon::isValidStatusMemberObject(retval)) {
return appendCommandStatus(out, WorkingSetCommon::getMemberObjectStatus(retval));
}
return appendCommandStatus(out,
@@ -168,6 +169,7 @@ namespace mongo {
<< "operation, executor returned "
<< PlanExecutor::statestr(state)));
}
+
invariant(planExecutor->isEOF());
invariant(STAGE_GROUP == planExecutor->getRootStage()->stageType());