summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/collection_scan.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/exec/collection_scan.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/exec/collection_scan.cpp')
-rw-r--r--src/mongo/db/exec/collection_scan.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp
index ab39d7d54b4..00547983fc8 100644
--- a/src/mongo/db/exec/collection_scan.cpp
+++ b/src/mongo/db/exec/collection_scan.cpp
@@ -133,12 +133,10 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) {
// only time we'd need to create a cursor after already getting a record out of it
// and updating our _lastSeenId.
if (!_cursor->seekExact(_lastSeenId)) {
- Status status(ErrorCodes::CappedPositionLost,
- str::stream() << "CollectionScan died due to failure to restore "
- << "tailable cursor position. "
- << "Last seen record id: " << _lastSeenId);
- *out = WorkingSetCommon::allocateStatusMember(_workingSet, status);
- return PlanStage::FAILURE;
+ uasserted(ErrorCodes::CappedPositionLost,
+ str::stream() << "CollectionScan died due to failure to restore "
+ << "tailable cursor position. "
+ << "Last seen record id: " << _lastSeenId);
}
}
@@ -152,14 +150,12 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) {
// returned this one prior to the resume.
auto recordIdToSeek = *_params.resumeAfterRecordId;
if (!_cursor->seekExact(recordIdToSeek)) {
- Status status(
+ uasserted(
ErrorCodes::KeyNotFound,
str::stream()
<< "Failed to resume collection scan: the recordId from which we are "
<< "attempting to resume no longer exists in the collection. "
<< "recordId: " << recordIdToSeek);
- *out = WorkingSetCommon::allocateStatusMember(_workingSet, status);
- return PlanStage::FAILURE;
}
}
@@ -205,11 +201,7 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) {
_lastSeenId = record->id;
if (_params.shouldTrackLatestOplogTimestamp) {
- auto status = setLatestOplogEntryTimestamp(*record);
- if (!status.isOK()) {
- *out = WorkingSetCommon::allocateStatusMember(_workingSet, status);
- return PlanStage::FAILURE;
- }
+ setLatestOplogEntryTimestamp(*record);
}
WorkingSetID id = _workingSet->allocate();
@@ -221,17 +213,14 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) {
return returnIfMatches(member, id, out);
}
-Status CollectionScan::setLatestOplogEntryTimestamp(const Record& record) {
+void CollectionScan::setLatestOplogEntryTimestamp(const Record& record) {
auto tsElem = record.data.toBson()[repl::OpTime::kTimestampFieldName];
- if (tsElem.type() != BSONType::bsonTimestamp) {
- Status status(ErrorCodes::InternalError,
- str::stream() << "CollectionScan was asked to track latest operation time, "
- "but found a result without a valid 'ts' field: "
- << record.data.toBson().toString());
- return status;
- }
+ uassert(ErrorCodes::Error(4382100),
+ str::stream() << "CollectionScan was asked to track latest operation time, "
+ "but found a result without a valid 'ts' field: "
+ << record.data.toBson().toString(),
+ tsElem.type() == BSONType::bsonTimestamp);
_latestOplogEntryTimestamp = std::max(_latestOplogEntryTimestamp, tsElem.timestamp());
- return Status::OK();
}
PlanStage::StageState CollectionScan::returnIfMatches(WorkingSetMember* member,