summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/dbcommands.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2020-05-18 18:20:48 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-29 18:44:40 +0000
commitd295b6646fcc815e73ad3085b212ad14c8c6de01 (patch)
tree3b17d6dcf49643018e5c1220fe61cb5808978ef0 /src/mongo/db/commands/dbcommands.cpp
parent84a7b81a73c7abfff42823b87612c9d50ea50e67 (diff)
downloadmongo-d295b6646fcc815e73ad3085b212ad14c8c6de01.tar.gz
SERVER-43821 Make PlanStage and PlanExecutor return errors by throwing
This eliminates the need for the FAILURE status codes in PlanStage and PlanExecutor, and brings query execution's error reporting more in line with that of the rest of the server. It also makes it easier for future implementations of PlanExecutor to comply with the interface.
Diffstat (limited to 'src/mongo/db/commands/dbcommands.cpp')
-rw-r--r--src/mongo/db/commands/dbcommands.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index e543e543de3..8d9d6b9d9c7 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -542,30 +542,28 @@ public:
long long size = 0;
long long numObjects = 0;
- RecordId loc;
- BSONObj obj;
- PlanExecutor::ExecState state;
- while (PlanExecutor::ADVANCED == (state = exec->getNext(&obj, &loc))) {
- if (estimate)
- size += avgObjSize;
- else
- size += collection->getRecordStore()->dataFor(opCtx, loc).size();
-
- numObjects++;
-
- if ((maxSize && size > maxSize) || (maxObjects && numObjects > maxObjects)) {
- result.appendBool("maxReached", true);
- break;
+ try {
+ RecordId loc;
+ while (PlanExecutor::ADVANCED == exec->getNext(static_cast<BSONObj*>(nullptr), &loc)) {
+ if (estimate)
+ size += avgObjSize;
+ else
+ size += collection->getRecordStore()->dataFor(opCtx, loc).size();
+
+ numObjects++;
+
+ if ((maxSize && size > maxSize) || (maxObjects && numObjects > maxObjects)) {
+ result.appendBool("maxReached", true);
+ break;
+ }
}
- }
-
- if (PlanExecutor::FAILURE == state) {
+ } catch (DBException& exception) {
LOGV2_WARNING(23801,
"Internal error while reading {namespace}",
"Internal error while reading",
"namespace"_attr = ns);
- uassertStatusOK(WorkingSetCommon::getMemberObjectStatus(obj).withContext(
- "Executor error while reading during dataSize command"));
+ exception.addContext("Executor error while reading during dataSize command");
+ throw;
}
ostringstream os;