summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/sbe/stages/scan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/sbe/stages/scan.cpp')
-rw-r--r--src/mongo/db/exec/sbe/stages/scan.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mongo/db/exec/sbe/stages/scan.cpp b/src/mongo/db/exec/sbe/stages/scan.cpp
index 6be957e2185..03f8a9271ca 100644
--- a/src/mongo/db/exec/sbe/stages/scan.cpp
+++ b/src/mongo/db/exec/sbe/stages/scan.cpp
@@ -338,6 +338,12 @@ PlanState ScanStage::getNext() {
// case it yields as the state will be completely overwritten after the next() call.
disableSlotAccess();
+ // This call to checkForInterrupt() may result in a call to save() or restore() on the entire
+ // PlanStage tree if a yield occurs. It's important that we call checkForInterrupt() before
+ // checking '_needsToCheckCappedPositionLost' since a call to restoreState() may set
+ // '_needsToCheckCappedPositionLost'.
+ checkForInterrupt(_opCtx);
+
if (_needsToCheckCappedPositionLost) {
_cursor->save();
if (!_cursor->restore(false /* do not tolerate capped position lost */)) {
@@ -348,8 +354,6 @@ PlanState ScanStage::getNext() {
_needsToCheckCappedPositionLost = false;
}
- checkForInterrupt(_opCtx);
-
auto res = _firstGetNext && _seekKeyAccessor;
auto nextRecord = res ? _cursor->seekExact(_key) : _cursor->next();
_firstGetNext = false;