diff options
Diffstat (limited to 'src/mongo/db/exec/collection_scan.cpp')
| -rw-r--r-- | src/mongo/db/exec/collection_scan.cpp | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp index 5898ac224d9..506ce18d1ce 100644 --- a/src/mongo/db/exec/collection_scan.cpp +++ b/src/mongo/db/exec/collection_scan.cpp @@ -185,26 +185,9 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) { << "attempting to resume no longer exists in the collection. " << "recordId: " << recordIdToSeek); } - - if (_params.resumeAfterRecordId && !_params.resumeAfterRecordId->isNull()) { - invariant(!_params.tailable); - invariant(_lastSeenId.isNull()); - // Seek to where we are trying to resume the scan from. Signal a KeyNotFound - // error if the record no longer exists. - // - // Note that we want to return the record *after* this one since we have already - // returned this one prior to the resume. - auto& recordIdToSeek = *_params.resumeAfterRecordId; - if (!_cursor->seekExact(recordIdToSeek)) { - 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); - } - } } + + return PlanStage::NEED_TIME; } if (_lastSeenId.isNull() && _params.direction == CollectionScanParams::FORWARD && @@ -371,24 +354,16 @@ PlanStage::StageState CollectionScan::returnIfMatches(WorkingSetMember* member, // In the future, we could change seekNear() to always return a record after minRecord in the // direction of the scan. However, tailable scans depend on the current behavior in order to // mark their position for resuming the tailable scan later on. - if (beforeStartOfRange(_params, *member)) { - _workingSet->free(memberID); - return PlanStage::NEED_TIME; - } - - if (!Filter::passes(member, _filter)) { - _workingSet->free(memberID); - if (_params.shouldReturnEofOnFilterMismatch) { - _commonStats.isEOF = true; - return PlanStage::IS_EOF; + if (!beforeStartOfRange(_params, *member) && Filter::passes(member, _filter)) { + if (_params.stopApplyingFilterAfterFirstMatch) { + _filter = nullptr; } + *out = memberID; + return PlanStage::ADVANCED; + } else { + _workingSet->free(memberID); return PlanStage::NEED_TIME; } - if (_params.stopApplyingFilterAfterFirstMatch) { - _filter = nullptr; - } - *out = memberID; - return PlanStage::ADVANCED; } bool CollectionScan::isEOF() { @@ -431,7 +406,9 @@ void CollectionScan::doReattachToOperationContext() { unique_ptr<PlanStageStats> CollectionScan::getStats() { // Add a BSON representation of the filter to the stats tree, if there is one. if (nullptr != _filter) { - _commonStats.filter = _filter->serialize(); + BSONObjBuilder bob; + _filter->serialize(&bob); + _commonStats.filter = bob.obj(); } unique_ptr<PlanStageStats> ret = std::make_unique<PlanStageStats>(_commonStats, STAGE_COLLSCAN); |
