HyukjinKwon opened a new pull request, #367: URL: https://github.com/apache/spark-connect-rust/pull/367
### What changes were proposed in this pull request? [SPARK-61187](https://issues.apache.org/jira/browse/SPARK-61187): raise `NO_ACTIVE_SESSION` when a result stream of a stopped session needs to reattach. - `ReattachableResponseStream::reattach` checks the closed state of the client (`ensure_open`) before each attempt, that is, before the ReattachExecute and before an ExecutePlan sent again. A closed client ends the stream with the `NO_ACTIVE_SESSION` error, through `fail`, which releases the stream as the other failures do. - The background ReleaseExecute of the stream is not changed. Official PySpark 4.3.0: the iterator reattaches through `client._stub`, which raises `NO_ACTIVE_SESSION` once the client is closed, so a read that needs a reattach after `stop()` fails with that error and sends nothing. ### Why are the changes needed? A result stream is reattached when the server ends it, for example after `senderMaxStreamDuration` for a query that runs for minutes. If the session is stopped while the stream is still being read, only the RPCs of the closed client were refused: the reattach of the open stream went to the server, so the stopped session kept reading. Official PySpark raises `NO_ACTIVE_SESSION` there. The server-side split of a stream cannot be triggered from a Python client, so this is covered by a Rust test with the mock server. ### Does this PR introduce _any_ user-facing change? Yes. A result stream that is read after its session was stopped and that needs a reattach raises `SparkConnectException` with `NO_ACTIVE_SESSION`, instead of returning more rows. ### How was this patch tested? - Rust `reattach_of_a_stream_whose_client_was_closed_raises_no_active_session` in `tests/deadlines.rs`, with the mock server: the first response is read, the client is closed, and the next read fails with `NO_ACTIVE_SESSION`; no ReattachExecute is sent, the stream is ended, and no ExecutePlan is sent again. It fails without the change, where the reattach returns the rest of the result. - The live `stop` and `close` drop-in tests, and the offline Python suites. - The lib tests of both crates (599 passed), the build of all tests, also with `wasm-udf`, and the offline Python suites (2227 passed, 8 skipped), and the deadline and reattach tests of the core against mock servers (14 passed); rustfmt passes, and clippy reports no diagnostics in the changed lines. ### 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]
