Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/10835#discussion_r50807613
--- Diff: core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
---
@@ -1116,23 +1120,33 @@ class DAGScheduler(
*/
private[scheduler] def handleTaskCompletion(event: CompletionEvent) {
val task = event.task
+ val taskId = task.partitionId
val stageId = task.stageId
val taskType = Utils.getFormattedClassName(task)
outputCommitCoordinator.taskCompleted(
stageId,
- task.partitionId,
+ taskId,
event.taskInfo.attemptNumber, // this is a task attempt number
event.reason)
- // The success case is dealt with separately below, since we need to
compute accumulator
- // updates before posting.
- if (event.reason != Success) {
- val attemptId = task.stageAttemptId
- listenerBus.post(SparkListenerTaskEnd(stageId, attemptId, taskType,
event.reason,
- event.taskInfo, event.taskMetrics))
+ // Reconstruct task metrics. Note: this may be null if the task has
failed.
+ val taskMetrics: TaskMetrics =
+ if (event.accumUpdates.nonEmpty) {
+ try {
+ TaskMetrics.fromAccumulatorUpdates(event.accumUpdates)
+ } catch {
+ case NonFatal(e) =>
+ logError(s"Error when attempting to reconstruct metrics for task
$taskId", e)
+ null
+ }
+ } else {
+ null
}
+ listenerBus.post(SparkListenerTaskEnd(
--- End diff --
I noticed that this post has now been moved to take place before the `if
(!stageIdToStage.contains(task.stageId))` logic on the next line. I think this
represents a change of behavior from the old code, where we wouldn't task end
events to the listener bus for cancelled stages.
Was this moved to make sure that it's posted for reasons other than
success? Just want to clarify.
---
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]