LantaoJin opened a new pull request #31119:
URL: https://github.com/apache/spark/pull/31119


   ### What changes were proposed in this pull request?
   #24595 introduced `private val runId: UUID = UUID.randomUUID` in 
`BroadcastExchangeExec` to cancel the broadcast execution in the Future when 
timeout happens. Since the runId is a random UUID instead of inheriting the job 
group id, when a SQL statement is cancelled, these broadcast sub-jobs are still 
executing. This PR uses the job group id of the outside thread as its `runId` 
to abort these broadcast sub-jobs when the SQL statement is cancelled.
   
   
   ### Why are the changes needed?
   When broadcasting a table takes too long and the SQL statement is cancelled. 
However, the background Spark job is still running and it wastes resources.
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   
   ### How was this patch tested?
   Manually test.
   Since broadcasting a table is too fast to cancel in UT, but it is very easy 
to verify manually: 
   1. Start a Spark thrift-server with less resource in YARN.
   2. When the driver is running but no executors are launched, submit a SQL 
which will broadcast tables from beeline.
   3. Cancel the SQL in beeline
   
   Without the patch, broadcast sub-jobs won't be cancelled.
   ![Screen Shot 2021-01-11 at 12 03 13 
PM](https://user-images.githubusercontent.com/1853780/104150975-ab024b00-5416-11eb-8bf9-b5167bdad80a.png)
   
   With this patch, broadcast sub-jobs will be cancelled.
   ![Screen Shot 2021-01-11 at 11 43 40 
AM](https://user-images.githubusercontent.com/1853780/104150994-be151b00-5416-11eb-80ff-313d423c8a2e.png)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to