Skip to content

[spark] Fix flaky interrupted CTAS test on Spark 3.2-3.4 - #11381

Open
LuciferYang wants to merge 2 commits into
apache:masterfrom
LuciferYang:fix/interrupted-ctas-kill-flag
Open

LuciferYang wants to merge 2 commits into
apache:masterfrom
LuciferYang:fix/interrupted-ctas-kill-flag

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

Fixes #11380. "Interrupted CTAS cleans up its table" cancels its job group with interruptOnCancel = true. Before Spark 4.0, a kill that lands after the executor's kill check but before Task.run records the task thread only marks the TaskContext; the thread is never interrupted, and nothing checks the mark before the task body runs (SPARK-44818 added that check in 4.0.0). The test UDF then stays in its 30 s Thread.sleep, and Range checks the mark only after the partition's 10 rows. The cancelled task holds one of the two local[2] slots for up to 300 s, and once both are held, later cases time out waiting for a task to start.

The UDF now sleeps in 20 ms steps and throws TaskKilledException once the TaskContext is marked killed. When the interrupt does arrive, Thread.sleep throws as before.

Tests

The change is test-only. On a fork, with the four cases repeated 40 times per suite on Spark 3.2-3.4 and Scala 2.12, the old UDF left a task running 5 s after cancelJobGroup in 4 of 480 cases, and a UDF that polls the mark the same way (with a 200 ms wait before it throws) in none of 480 (run).

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.

[Bug] [spark] "Interrupted CTAS cleans up its table" fails intermittently on Spark 3.2-3.4

1 participant