ChuckLin2025 opened a new pull request, #60544: URL: https://github.com/apache/spark/pull/60544
### What changes were proposed in this pull request? Make the test wait until the stop thread has entered `EventLoop.stop()` before it probes the thread's state. The test's event loop overrides `stop()` to count down a latch before calling `super.stop()`. ### Why are the changes needed? The test assumes that once the stop thread reads `WAITING`, it is parked in `EventLoop.stop()`'s join, which only starts after the loop is marked stopped. But `DAGScheduler.stop()` first calls `shutdownNow()` on `messageScheduler` and `shuffleMergeFinalizeScheduler`, which take each executor's `mainLock`. A thread parked on that lock also reads `WAITING`, and if the test's interrupt lands there, the uninterruptible acquire clears the interrupt flag until it gets the lock. Both state checks then pass before the loop is stopped. When the test releases the in-flight replay, the loop goes on to run the second deferred replay, and the test fails with: ``` HashMap(0 -> 42, 1 -> 43) did not equal HashMap(0 -> 42) ``` After the latch fires, the only place the stop thread can wait is the join, which starts after `stopped` is set. ### Does this PR introduce _any_ user-facing change? No. Test-only. ### How was this patch tested? - Reproduced the race deterministically: in the test's event loop, made `stop()` park on a `ReentrantLock` held by the test until after the in-flight replay is released, before calling `super.stop()`. The unmodified test then fails every time with the assertion above. - With this change, made `stop()` park uninterruptibly for 2 seconds before reaching the new latch and `super.stop()`. The test passes, because it no longer probes the stop thread until `EventLoop.stop()` is entered. - `build/sbt "core/testOnly org.apache.spark.scheduler.DAGSchedulerSuite"`: 318 passed, 0 failed. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Isaac (Claude Opus 5.5) This pull request and its description were written by Isaac. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
