[SPARK-37043][SQL] Cancel all running job when main query is going to final plan #41536
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This is a re-work pr for #34316. The reason before we can not safely cancel running stages is we use the stage status to track the final sql execution status, but it is not a issue any more since #38302.
Why are the changes needed?
We see stage was still running after AQE plan finished. This is because the plan which contains a join with one empty side has been converted to LocalTableScanExec during AQEOptimizer, but the other side of this join is still running (shuffle map stage).
It's no meaning to keep running that stage, so It's better to cancel the running stage when main query is going to final plan in case wasting the task resource.
Does this PR introduce any user-facing change?
maybe yes, the unnecessary running stage will be cancelled.
How was this patch tested?
add test