[I2B55F]: Fix: Consumer gets blocked if producer gets cancelled

This commit is contained in:
rajeevrastogi 2020-12-28 17:58:15 +05:30
parent 43c964fd9e
commit 574afd4864
2 changed files with 6 additions and 6 deletions

View File

@ -555,9 +555,6 @@ public final class SqlStageExecution
}
if (finishedTasks.containsAll(allTasks)) {
stateMachine.transitionToFinished();
if (isReuseTableScanEnabled(stateMachine.getSession())) {
setReuseTableScanMappingIdStatus(stateMachine);
}
}
}
}
@ -568,9 +565,9 @@ public final class SqlStageExecution
}
//Assuming there will be only one table scan in one stage
private static synchronized void setReuseTableScanMappingIdStatus(StageStateMachine state)
public static synchronized void setReuseTableScanMappingIdStatus(StageStateMachine state)
{
if (state.getProducerScanNode() == null) {
if (!isReuseTableScanEnabled(state.getSession()) || state.getProducerScanNode() == null) {
return;
}

View File

@ -203,23 +203,26 @@ public class StageStateMachine
public boolean transitionToFinished()
{
SqlStageExecution.setReuseTableScanMappingIdStatus(this);
return stageState.setIf(FINISHED, currentState -> !currentState.isDone());
}
public boolean transitionToCanceled()
{
SqlStageExecution.setReuseTableScanMappingIdStatus(this);
return stageState.setIf(CANCELED, currentState -> !currentState.isDone());
}
public boolean transitionToAborted()
{
SqlStageExecution.setReuseTableScanMappingIdStatus(this);
return stageState.setIf(ABORTED, currentState -> !currentState.isDone());
}
public boolean transitionToFailed(Throwable throwable)
{
requireNonNull(throwable, "throwable is null");
SqlStageExecution.setReuseTableScanMappingIdStatus(this);
failureCause.compareAndSet(null, Failures.toFailure(throwable));
boolean failed = stageState.setIf(FAILED, currentState -> !currentState.isDone());
if (failed) {