Skip to content

[SPARK-58446][CORE] Prevent late task events from corrupting pending task state - #57651

Open
j1wonpark wants to merge 1 commit into
apache:masterfrom
j1wonpark:fix/SPARK-58446-dynamic-allocation-late-task-start
Open

[SPARK-58446][CORE] Prevent late task events from corrupting pending task state#57651
j1wonpark wants to merge 1 commit into
apache:masterfrom
j1wonpark:fix/SPARK-58446-dynamic-allocation-late-task-start

Conversation

@j1wonpark

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR skips pending-task bookkeeping for TaskStart and SpeculativeTaskSubmitted events when the corresponding stage attempt has already completed.

Running-task accounting remains unchanged for late TaskStart events so that matching TaskEnd events are handled correctly.

Regression tests were added for regular task starts, speculative task starts, and speculative task submissions after StageCompleted.

Why are the changes needed?

After StageCompleted removes the stage metadata, a late TaskStart event can recreate task-index state. Processing the matching TaskEnd can then produce a negative pending task count.

When dynamic allocation uses minExecutors=0, this can leave the executor target at zero and prevent later stages from requesting executors.

Does this PR introduce any user-facing change?

Yes. Late task events from completed stages no longer prevent subsequent stages from requesting executors when dynamic allocation is enabled.

How was this patch tested?

Added regression tests covering late regular task starts, speculative task starts, and speculative task submissions.

The three new tests failed against upstream/master and passed with this patch.

build/sbt 'core/testOnly org.apache.spark.ExecutorAllocationManagerSuite'

All 40 tests passed.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Codex (GPT-5.6)

…task state

Signed-off-by: Jiwon Park <jpark92@outlook.kr>
@uros-b

uros-b commented Jul 30, 2026

Copy link
Copy Markdown
Member

Thank you @j1wonpark!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants