LuciferYang opened a new issue, #11380:
URL: https://github.com/apache/paimon/issues/11380

   **Search before asking**
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   **Paimon version**
   master @ 6a9e258775
   
   **Compute Engine**
   Spark 3.2.4, 3.3.4 and 3.4.4, as built by the `Java / Spark 3` CI jobs. The 
test is skipped on Spark 3.5 and later.
   
   **Minimal reproduce step**
   The two `v2=true` cases of "Interrupted CTAS cleans up its table" in 
`V2WriteDistributionTest` (defined in `V2WriteRequireDistributionTest.scala`) 
sometimes fail together, each when its 30 s wait runs out:
   
   ```
   taskStarted.await(30L, SECONDS) was false CTAS did not start its input tasks 
(V2WriteRequireDistributionTest.scala:557)
   ```
   
   In the 200 most recent CI runs (November 20 to 23), 94 `Java / Spark 3 / 
Scala 2.13` jobs ran to the end and 4 of them failed this way: one on master 
(run 45022058639) and three on PRs, once in `paimon-spark-3.2` and three times 
in `paimon-spark-3.3`. None of the 96 Scala 2.12 jobs did, but the fork runs 
below reproduce it on 2.12.
   
   **What doesn't meet your expectations?**
   The test should not depend on scheduling; Paimon's CTAS cleanup is not at 
fault. The test 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](https://issues.apache.org/jira/browse/SPARK-44818) added that 
check in 4.0.0 only). The test UDF sleeps 30 s per row without checking the 
mark, and Range checks it only after a whole batch, here the partition's 10 
rows. So the cancelled task keeps one of the two `local[2]` slots for up to 300 
s, and once both are held, later cases cannot start a task.
   
   **Anything else?**
   On a fork, with the four cases repeated 40 times per suite on Spark 3.2-3.4 
and Scala 2.12, the sleeping UDF left a task running 5 s after `cancelJobGroup` 
in 4 of 480 cases. A UDF that also polls `TaskContext.isInterrupted()` (and 
waits 200 ms after seeing the mark before it throws) left none in 480, and it 
recorded 4 tasks that were already marked killed at their first row while their 
thread was not interrupted: 
https://github.com/LuciferYang/paimon/actions/runs/45150701309
   
   **Are you willing to submit a PR?**
   - [x] I'm willing to submit a PR!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to