Skip to content

Commit

Permalink
SERVER-81812 BlockToRowStage will check for interrupt but won't yield
Browse files Browse the repository at this point in the history
  • Loading branch information
parker-felix authored and Evergreen Agent committed Oct 12, 2023
1 parent 9d8ecca commit 5bbb8a5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mongo/db/exec/sbe/stages/co_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void CoScanStage::open(bool reOpen) {
PlanState CoScanStage::getNext() {
auto optTimer(getOptTimer(_opCtx));

checkForInterrupt(_opCtx);
checkForInterruptAndYield(_opCtx);

// Run forever.
return trackPlanState(PlanState::ADVANCED);
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/exec/sbe/stages/column_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ PlanState ColumnScanStage::getNext() {
// call.
disableSlotAccess();

checkForInterrupt(_opCtx);
checkForInterruptAndYield(_opCtx);

if (_scanTracker.isScanningRowstore()) {
_scanTracker.track();
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/exec/sbe/stages/ix_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ PlanState IndexScanStageBase::getNext() {
// state in case it yields as the state will be completely overwritten after the call.
disableSlotAccess();

checkForInterrupt(_opCtx);
checkForInterruptAndYield(_opCtx);

do {
switch (_scanState) {
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/exec/sbe/stages/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ PlanState ScanStage::getNext() {
// 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);
checkForInterruptAndYield(_opCtx);

if (_needsToCheckCappedPositionLost) {
_cursor->save();
Expand Down Expand Up @@ -1097,7 +1097,7 @@ PlanState ParallelScanStage::getNext() {
return trackPlanState(PlanState::IS_EOF);
}

checkForInterrupt(_opCtx);
checkForInterruptAndYield(_opCtx);

boost::optional<Record> nextRecord;

Expand Down
15 changes: 14 additions & 1 deletion src/mongo/db/exec/sbe/stages/stages.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class CanInterrupt {
* Checks for interrupt if necessary. If yielding has been enabled for this object, then also
* performs a yield if necessary.
*/
void checkForInterrupt(OperationContext* opCtx) {
void checkForInterruptAndYield(OperationContext* opCtx) {
invariant(opCtx);

if (!_yieldPolicy) {
Expand All @@ -521,6 +521,19 @@ class CanInterrupt {
}
}

/**
* Checks for interrupt if necessary. Will never yield regardless of the yielding policy.
* Should only be used for ValueBlock stages.
*/
void checkForInterrupt(OperationContext* opCtx) {
invariant(opCtx);

if (--_interruptCounter == 0) {
_interruptCounter = kInterruptCheckPeriod;
opCtx->checkForInterrupt();
}
}

void attachNewYieldPolicy(PlanYieldPolicy* yieldPolicy) {
auto stage = static_cast<T*>(this);
for (auto&& child : stage->_children) {
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/exec/sbe/stages/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void WindowStage::open(bool reOpen) {

PlanState WindowStage::getNext() {
auto optTimer(getOptTimer(_opCtx));
checkForInterrupt(_opCtx);
checkForInterruptAndYield(_opCtx);

// Fetch at least the current document into cache.
_currId++;
Expand Down

0 comments on commit 5bbb8a5

Please sign in to comment.