diff --git a/core/src/main/scala/org/apache/spark/executor/Executor.scala b/core/src/main/scala/org/apache/spark/executor/Executor.scala index afba6d8e5f49e..acae448a9c66f 100644 --- a/core/src/main/scala/org/apache/spark/executor/Executor.scala +++ b/core/src/main/scala/org/apache/spark/executor/Executor.scala @@ -361,10 +361,13 @@ private[spark] class Executor( Option(taskRunner.task).flatMap(_.metrics).foreach { metrics => metrics.updateShuffleReadMetrics if (isLocal) { - // make a deep copy of it + // JobProgressListener will hold an reference of it during + // onExecutorMetricsUpdate(), then JobProgressListener can not see + // the changes of metrics any more, so make a deep copy of it val copiedMetrics = Utils.deserialize[TaskMetrics](Utils.serialize(metrics)) tasksMetrics += ((taskRunner.taskId, copiedMetrics)) } else { + // It will be copied by serialization tasksMetrics += ((taskRunner.taskId, metrics)) } }