diff options
author | Jason Rassi <rassi@10gen.com> | 2014-12-09 16:13:17 -0500 |
---|---|---|
committer | Jason Rassi <rassi@10gen.com> | 2014-12-09 18:17:09 -0500 |
commit | efe368fa7a6b4c1ca6077fdb2560a33dfdc82337 (patch) | |
tree | c02626fa1d411f399a3ea7df6ffebaf1b5a212b1 /src | |
parent | 23fb35b7a52d0d50829a6bb9a47954374ab2b61f (diff) | |
download | mongo-efe368fa7a6b4c1ca6077fdb2560a33dfdc82337.tar.gz |
SERVER-16469 findAndModify runImpl(): improve error reporting
Previously, findAndModify ignored errors encountered in calls to
PlanExecutor::getNext() when searching for the document to modify.
Now, errors are bubbled up to the user.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/commands/find_and_modify.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index 66250c8af81..56410a59916 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -35,6 +35,7 @@ #include "mongo/db/commands.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/dbhelpers.h" +#include "mongo/db/exec/working_set_common.h" #include "mongo/db/projection.h" #include "mongo/db/ops/delete.h" #include "mongo/db/ops/update.h" @@ -239,9 +240,24 @@ namespace mongo { scoped_ptr<PlanExecutor> exec(rawExec); - if (PlanExecutor::ADVANCED == exec->getNext(&doc, NULL)) { + PlanExecutor::ExecState state = exec->getNext(&doc, NULL); + if (PlanExecutor::ADVANCED == state) { found = true; } + else if (PlanExecutor::FAILURE == state || PlanExecutor::DEAD == state) { + if (PlanExecutor::FAILURE == state && + WorkingSetCommon::isValidStatusMemberObject(doc)) { + const Status errorStatus = WorkingSetCommon::getMemberObjectStatus(doc); + invariant(!errorStatus.isOK()); + uasserted(errorStatus.code(), errorStatus.reason()); + } + uasserted(ErrorCodes::OperationFailed, + str::stream() << "executor returned " << PlanExecutor::statestr(state) + << " while finding document to update"); + } + else { + invariant(PlanExecutor::IS_EOF == state); + } } BSONObj queryModified = query; |