Skip to content

Commit

Permalink
MSQ: Fix two issues with phase transitions. (#17053)
Browse files Browse the repository at this point in the history
1) ControllerQueryKernel: Update readyToReadResults to acknowledge that sorting stages can
   go directly from READING_INPUT to RESULTS_READY.

2) WorkerStageKernel: Ignore RESULTS_COMPLETE if work is already finished, which can happen
   if the transition to FINISHED comes early due to a downstream LIMIT.
  • Loading branch information
gianm authored Sep 13, 2024
1 parent 99e8f66 commit 654e0b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,11 +676,10 @@ private boolean readyToReadResults(final StageId stageId, final ControllerStageP
{
if (stageOutputChannelModes.get(stageId) == OutputChannelMode.MEMORY) {
if (getStageDefinition(stageId).doesSortDuringShuffle()) {
// Stages that sort during shuffle go through a READING_INPUT phase followed by a POST_READING phase
// (once all input is read). These stages start producing output once POST_READING starts.
return newPhase == ControllerStagePhase.POST_READING;
// Sorting stages start producing output when they finish reading their input.
return newPhase.isDoneReadingInput();
} else {
// Can read results immediately.
// Non-sorting stages start producing output immediately.
return newPhase == ControllerStagePhase.NEW;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ public void setResultsComplete(Object resultObject)
throw new NullPointerException("resultObject must not be null");
}

if (phase.isTerminal()) {
// Ignore RESULTS_COMPLETE if work is already finished. This can happen if we transition to FINISHED early
// due to a downstream stage including a limit.
return;
}

transitionTo(WorkerStagePhase.RESULTS_COMPLETE);
this.resultObject = resultObject;
}
Expand Down

0 comments on commit 654e0b4

Please sign in to comment.