HyukjinKwon opened a new pull request, #548:
URL: https://github.com/apache/spark-connect-rust/pull/548
### What changes were proposed in this pull request?
A follow-up of #545 (SPARK-61498), from a review of it. #545 made the wait
of an execution (`watched` in `crates/spark-connect-core/src/runtime.rs`) end
at the second Ctrl-C while the interrupt that the first one started hangs. Its
sibling `watched_abortable`, the wait of `block_on_abortable`, still stopped
polling the signal watch once the watch had returned `Watch::Interrupt`: its
tick arm was off while an interrupt ran, and once its future had ended it
awaited the interrupt with no bound. So a later signal was not seen.
`watched_abortable` now does what `watched` does:
- The polls go on after the first interrupt is spawned. A later
`Watch::Abort` cancels the interrupt and ends the wait with `None`, as an abort
does before it.
- When the future has ended while the interrupt runs, the interrupt is
awaited with the polls, and a `Watch::Abort` cancels it. The output of the
future is still returned.
- The first signal is unchanged: one interrupt is spawned, and the future is
driven on.
### Why are the changes needed?
The two waits behaved differently for the same signals. `block_on_abortable`
has one caller, the release of `SparkSession::stop`. Its watch returns
`Watch::Interrupt` only while the calling thread waits for an execution. So in
the Python client this is reached only when `stop()` runs inside such a wait. A
`stop()` from a progress handler does not reach it, since the handlers run
after the wait of the stream read. The wait now holds for any caller, as
`watched` does, rather than hang until the interrupt or the release ends.
### Does this PR introduce _any_ user-facing change?
No for the cases above. The Rust API installs no signal watch, and in the
Python client the path needs a `stop()` inside the wait of an execution.
### How was this patch tested?
- Two tests in `runtime.rs`, next to #545's tests of `watched`. They run the
wait under a scripted watch on a thread of their own, with a 5-second bound, so
that a wait that does not end fails the test instead of hanging it:
- `test_a_second_signal_ends_an_abortable_wait_while_its_interrupt_hangs`:
an interrupt that never ends, then an abort. The wait ends with `None`, and the
interrupt is cancelled.
-
`test_a_second_signal_ends_an_abortable_wait_while_its_future_waits_after_the_interrupt`:
the same while the future still waits after the interrupt. It also checks that
the output is returned after a finished interrupt when no second signal comes.
Both fail at the 5-second bound without the change and pass with it.
- `cargo test -p apache-spark-connect-core --release --lib` (218 passed),
`cargo test -p apache-spark-connect -p apache-spark-connect-core --release
--no-run`, `cargo build -p pyspark-rs --release`, the offline drop-in and ML
suites (2005 passed), the live `e2e_session_catalog` and `e2e_reattach_drop`
against a Spark 4.3.0 server, the `stop`/`sigint`/`interrupt`/`release` subset
of `test_dropin_e2e.py`, `cargo fmt --all -- --check`, and
`scripts/audit_no_stubs.sh`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: 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]