summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2014-12-09 16:13:17 -0500
committerJason Rassi <rassi@10gen.com>2014-12-09 18:17:09 -0500
commitefe368fa7a6b4c1ca6077fdb2560a33dfdc82337 (patch)
treec02626fa1d411f399a3ea7df6ffebaf1b5a212b1 /src/mongo/db/commands
parent23fb35b7a52d0d50829a6bb9a47954374ab2b61f (diff)
downloadmongo-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/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp18
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;