HyukjinKwon opened a new pull request, #535:
URL: https://github.com/apache/spark-connect-rust/pull/535
### What changes were proposed in this pull request?
A follow-up of SPARK-61407 (#491), which let a Ctrl-C end a call that waits
for an unreachable or retrying server through `interruptible`:
- The calls of the Python client that still waited for the server with a
bare `py.detach` now wait through `interruptible`, or `until_signal` for the
transport stub methods. These are the conf
`get`/`set`/`unset`/`getAll`/`isModifiable`, `schema`, `columns`, `dtypes`,
`printSchema` and the other analyze-based properties and methods,
`persist`/`cache`, `explain`, `cloneSession`,
`interruptAll`/`interruptTag`/`interruptOperation`, the artifact upload, the
`RustConnectStub` methods, and others in `group.rs`, `infer.rs`,
`observation.rs`, `pipelines.rs`, `pyarrow_import.rs`, `streaming.rs` and
`types.rs`. Waits that only build a plan or run on the CPU are left alone.
- When the Interrupt sent for a signal fails, its error is raised in place
of the `KeyboardInterrupt`, with the `KeyboardInterrupt` as its `__context__`,
as PySpark's `interrupt_operation` raises out of the `except KeyboardInterrupt`
of an execution. The failure also ends the wait at once, so a held
`toLocalIterator` no longer ignores the first Ctrl-C. The done error of a
progress handler still takes precedence.
### Why are the changes needed?
Without the wait watch, a signal was not checked while these calls waited,
so a hung or unreachable server held them until the watchdog, 8 to 75 s.
PySpark raises `KeyboardInterrupt` about 1 s after the SIGINT:
```python
spark = SparkSession.builder.remote("sc://127.0.0.1:1").getOrCreate()
spark.conf.get("spark.sql.shuffle.partitions") # SIGINT at 0.5 s
# before: blocked until the watchdog; after (and PySpark 4.3.0):
KeyboardInterrupt at once
```
The same held for `conf.set`, `df.schema`, `addArtifacts`, `cloneSession`
and `interruptAll`, against a hung server (accepts the connection, never
answers) and an unreachable one.
With a server whose Interrupt answers `INTERNAL`, a blocked `collect` raised
`KeyboardInterrupt`, and a held `toLocalIterator` ignored the first Ctrl-C
while its job kept running. PySpark raises the `SparkConnectGrpcException`
(`INTERNAL`) of the interrupt at once.
A known gap is left. For `addArtifacts` and `copyFromLocalToFs`, a signal
ends the retry sleeps of the upload, but an AddArtifacts request that a server
accepts and never answers still waits for its deadline. The core does not abort
that await, and changing that belongs to the core retry and deadline code.
### Does this PR introduce _any_ user-facing change?
Yes. A Ctrl-C ends these calls at once against an unreachable or hung
server, and a failed interrupt raises its error with the `KeyboardInterrupt` as
context, as PySpark does.
### How was this patch tested?
- New offline tests in `python/tests/test_dropin_offline.py`, which fail on
master:
`test_sigint_ends_a_call_that_waits_for_the_server_at_once[unreachable|hung]`
(SIGINT at 0.5 s in a subprocess; `conf.get`, `conf.set`, `schema`,
`cloneSession` and `interruptAll` raise within 3 s, and `addArtifacts` does too
against the unreachable server),
`test_a_failed_interrupt_of_a_blocked_collect_is_raised_with_the_signal_as_context`,
and
`test_a_failed_interrupt_of_a_held_local_iterator_is_raised_at_the_first_signal`.
- The small-stack tests of SPARK-61400 pass. The extra copy of the analyze
future that the wait watch made, which overflowed them, is gone since
SPARK-61469 (#522).
- The offline suite (1844 passed), the e2e suites `test_dropin_e2e.py`,
`test_arrow_e2e.py` and `test_ml_e2e.py` against a Spark 4.3.0 server, the Rust
library tests, the `--no-run` builds (with and without `wasm-udf`), `cargo fmt
--check`, `scripts/audit_no_stubs.sh` and the ruff gates.
### 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]