[SPARK-59819][CORE] Fix Resubmitted task end accounting in AppStatusListener - #59092
Open
dongjoon-hyun wants to merge 1 commit into
Open
dongjoon-hyun wants to merge 1 commit into
dongjoon-hyun wants to merge 1 commit into
Conversation
dongjoon-hyun
force-pushed
the
SPARK-59819
branch
from
September 28, 2026 06:25
368718e to
ab00607
Compare
HyukjinKwon
approved these changes
Sep 28, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR aims to fix two
Resubmittedaccounting bugs inAppStatusListener.onTaskEnd.When an executor is lost,
TaskSetManager.executorLostpostsSparkListenerTaskEndwithResubmittedreason for the already-successful shuffle map tasks of that executor (without external shuffle service or on decommission) if the task set is not zombie. This event reuses the finishedTaskInfoof the successful attempt and has no matchingSparkListenerTaskStart. Since SPARK-41187 (#38702),onTaskEndusesactiveDelta = 0forResubmitted, but the following places still handle it like a normal task end.numActiveTasksunconditionally. This PR usesactiveDeltalike the other active task counters.ExecutorStageSummary.taskTimeandExecutorSummary.totalDurationaddevent.taskInfo.durationagain although the duration of the successful attempt was already counted. This PR skips them forResubmittedlike the executor-level task metrics, which are already skipped forResubmitted.Why are the changes needed?
To show correct values.
numActiveTasksof the speculation summary becomes negative (e.g.-1), and nothing corrects it later because onlyonTaskStartandonTaskEndupdate it. This value is stored inSpeculationStageSummaryWrapperand shown via the REST APIspeculationSummaryfield and theSpeculation Summarytable of the stage page.Resubmittedtask end, the duration of the successful attempt is counted twice inExecutorStageSummary.taskTime(Task TimeofAggregated Metrics by Executortable in the stage page).ExecutorSummary.totalDuration(Task Time (GC Time)in the executors page andtotalDuration_seconds_totalin the Prometheus metrics) is also counted twice if theResubmittedtask end arrives beforeSparkListenerExecutorRemovedof the lost executor. This is timing-dependent becauseCoarseGrainedSchedulerBackendpostsSparkListenerExecutorRemovedright afterTaskSchedulerImpl.executorLost, while theResubmittedtask end is posted asynchronously by theDAGSchedulerevent loop. Note that the oldExecutorsListenerof Apache Spark 2.2 ignoredResubmittedtask ends including the duration, but SPARK-20646 ([SPARK-20646][core] Port executors page to new UI backend. #19678) kept only the task metrics part when porting it toAppStatusListener.These were found during the review of #58968.
Does this PR introduce any user-facing change?
Yes, this fixes the incorrect values in the Spark UI, REST API, and Prometheus metrics. The negative
numActiveTasksof the speculation summary exists since Apache Spark v3.3.0 (2022-06-09), and the double-counted task duration exists since Apache Spark v2.3.0 (2018-02-22).How was this patch tested?
Pass the CIs with the newly added test case. I also manually verified that the new test case fails without this fix.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5