Github user andrewor14 commented on the pull request:
https://github.com/apache/spark/pull/6817#issuecomment-123817484
Almost, you'll also have to check whether the task actually succeeded. If
it failed, we will expect it to be resubmitted it later. Also, you'll need to
call `allocationManager.onSchedulerBacklogged()` to signal that a task is
expected to run later. Something like the following:
```
val taskId = ...
val taskIndex = ...
val stageId = ...
// If the task failed, we expect it to be resubmitted later. To ensure we
have
// enough resources to run the resubmitted task, we need to mark the
scheduler
// as backlogged again (SPARK-8366).
if (taskEnd.reason != Success) {
if (stageScheduledAllTasks(stageId)) {
allocationManager.onSchedulerBacklogged
}
stageIdToTaskIndices.get(stageId).foreach { taskIndices =>
taskIndices.remove(taskIndex)
}
}
/**
* Return whether the specified stage has finished scheduling all tasks.
* Return false if the stage has not been submitted yet.
*/
private def stageScheduledAllTasks(stageId: Int): Boolean = {
val numTasksScheduled = stageIdToTaskIndices.get(stageId).map(_.size)
val numTasksTotal = stageIdToNumTasks.get(stageId)
numTasksScheduled.isDefined && numTasksScheduled == numTasksTotal
}
```
The reason why I factored out `stageSchedulerAllTasks` is to avoid
duplicating code that already exists in `onTaskStart`.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]