GitHub user zhaorongsheng opened a pull request: https://github.com/apache/spark/pull/16389
[SPARK-18981][Core]The job hang problem when speculation is on ## What changes were proposed in this pull request? The root cause of this issue is that `ExecutorAllocationListener` gets the speculated task end info after the stage end event handling which let `numRunningTasks = 0`. Then it let `numRunningTasks -= 1` so the #numRunningTasks is negative. When calculate #maxNeeded in method `maxNumExecutorsNeeded()`, the value may be 0 or negative. So `ExecutorAllocationManager` does not request container and the job will be hung. This PR changes the method `onTaskEnd()` in `ExecutorAllocationListener`. When `stageIdToNumTasks` contains the taskEnd's stageId, let #numRunningTasks minus 1. ## How was this patch tested? This patch was tested in the method `test("SPARK-18981...)` of ExecutorAllocationManagerSuite.scala. Create two taskInfos and one of them is speculated task. After the stage ending event, the speculated task ending event is posted to listener. You can merge this pull request into a Git repository by running: $ git pull https://github.com/zhaorongsheng/spark master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/16389.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #16389 ---- commit 1e191136581a22ed7cafd42e8b85e9a057b71171 Author: roncen.zhao <roncen.z...@vipshop.com> Date: 2016-12-23T16:38:34Z resolve the job hang problem when speculation is on ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org