summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Shweky <neilshweky@gmail.com>2021-11-04 18:08:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-04 18:36:44 +0000
commitd54acf1b792de6f7a8b82e49a1e94a7c24c938b0 (patch)
tree7a1f13f69ca48c22f52e2ee8d099e77af5762b37
parent9b27d9c7582ca544b0c27b119107b57b4e2b8d50 (diff)
downloadmongo-d54acf1b792de6f7a8b82e49a1e94a7c24c938b0.tar.gz
SERVER-59597 remove unneeded checks in scan
-rw-r--r--src/mongo/db/exec/sbe/stages/ix_scan.cpp4
-rw-r--r--src/mongo/db/exec/sbe/stages/scan.cpp58
2 files changed, 26 insertions, 36 deletions
diff --git a/src/mongo/db/exec/sbe/stages/ix_scan.cpp b/src/mongo/db/exec/sbe/stages/ix_scan.cpp
index 9e73305f0a1..b913c5575d9 100644
--- a/src/mongo/db/exec/sbe/stages/ix_scan.cpp
+++ b/src/mongo/db/exec/sbe/stages/ix_scan.cpp
@@ -326,10 +326,6 @@ PlanState IndexScanStage::getNext() {
// state in case it yields as the state will be completely overwritten after the call.
disableSlotAccess();
- if (!_cursor) {
- return trackPlanState(PlanState::IS_EOF);
- }
-
checkForInterrupt(_opCtx);
if (_firstGetNext) {
diff --git a/src/mongo/db/exec/sbe/stages/scan.cpp b/src/mongo/db/exec/sbe/stages/scan.cpp
index 5a50224861a..ea4c7ba85fe 100644
--- a/src/mongo/db/exec/sbe/stages/scan.cpp
+++ b/src/mongo/db/exec/sbe/stages/scan.cpp
@@ -303,7 +303,7 @@ void ScanStage::open(bool reOpen) {
_cursor = _coll->getCursor(_opCtx, _forward);
}
} else {
- _cursor.reset();
+ MONGO_UNREACHABLE_TASSERT(5959701);
}
_open = true;
@@ -317,10 +317,6 @@ PlanState ScanStage::getNext() {
// case it yields as the state will be completely overwritten after the next() call.
disableSlotAccess();
- if (!_cursor) {
- return trackPlanState(PlanState::IS_EOF);
- }
-
checkForInterrupt(_opCtx);
auto res = _firstGetNext && _seekKeyAccessor;
@@ -761,39 +757,37 @@ void ParallelScanStage::open(bool reOpen) {
_coll = restoreCollection(_opCtx, *_collName, _collUuid, *_catalogEpoch);
}
- if (_coll) {
- {
- stdx::unique_lock lock(_state->mutex);
- if (_state->ranges.empty()) {
- auto ranges = _coll->getRecordStore()->numRecords(_opCtx) / 10240;
- if (ranges < 2) {
- _state->ranges.emplace_back(Range{RecordId{}, RecordId{}});
- } else {
- if (ranges > 1024) {
- ranges = 1024;
- }
- auto randomCursor = _coll->getRecordStore()->getRandomCursor(_opCtx);
- invariant(randomCursor);
- std::set<RecordId> rids;
- while (ranges--) {
- auto nextRecord = randomCursor->next();
- if (nextRecord) {
- rids.emplace(nextRecord->id);
- }
- }
- RecordId lastid{};
- for (auto id : rids) {
- _state->ranges.emplace_back(Range{lastid, id});
- lastid = id;
+ {
+ stdx::unique_lock lock(_state->mutex);
+ if (_state->ranges.empty()) {
+ auto ranges = _coll->getRecordStore()->numRecords(_opCtx) / 10240;
+ if (ranges < 2) {
+ _state->ranges.emplace_back(Range{RecordId{}, RecordId{}});
+ } else {
+ if (ranges > 1024) {
+ ranges = 1024;
+ }
+ auto randomCursor = _coll->getRecordStore()->getRandomCursor(_opCtx);
+ invariant(randomCursor);
+ std::set<RecordId> rids;
+ while (ranges--) {
+ auto nextRecord = randomCursor->next();
+ if (nextRecord) {
+ rids.emplace(nextRecord->id);
}
- _state->ranges.emplace_back(Range{lastid, RecordId{}});
}
+ RecordId lastid{};
+ for (auto id : rids) {
+ _state->ranges.emplace_back(Range{lastid, id});
+ lastid = id;
+ }
+ _state->ranges.emplace_back(Range{lastid, RecordId{}});
}
}
-
- _cursor = _coll->getCursor(_opCtx);
}
+ _cursor = _coll->getCursor(_opCtx);
+
_open = true;
}