tdcmeehan opened a new pull request, #517: URL: https://github.com/apache/spark-connect-rust/pull/517
### What changes were proposed in this pull request? [SPARK-61410](https://issues.apache.org/jira/browse/SPARK-61410): raise `NO_ACTIVE_SESSION` from the first call after the server-side session changed, as PySpark does. `SparkConnectClient::error_from_status` now returns `NO_ACTIVE_SESSION` when the error of the server has an `errorId` and the client is closed, instead of fetching the details of the error through the closed client and falling back to the bare error. An `INVALID_HANDLE.SESSION_CHANGED` error closes the client before this point, so the first call after the server restarted raises `NO_ACTIVE_SESSION`. ### Why are the changes needed? PySpark fetches the enriched error through its `_stub`, which raises `NO_ACTIVE_SESSION` once the client is closed; that exception is not a `grpc.RpcError`, so it replaces the error of the server. The Rust client raised `INVALID_HANDLE.SESSION_CHANGED` from the first call and `NO_ACTIVE_SESSION` only from the second. Measured against an OSS Spark 4.3.0 Connect server on loopback, by setting the client's observed server-side session ID (`_client._server_session_id`) to a random UUID and calling `spark.range(3).collect()` twice (the server answers with `SESSION_CHANGED`, as after a restart): * pyspark-client 4.3.0: `SparkConnectException` `NO_ACTIVE_SESSION`, then `SparkConnectException` `NO_ACTIVE_SESSION`. * spark-connect-rust master 125654b: `UnknownException` `INVALID_HANDLE.SESSION_CHANGED`, then `SparkConnectException` `NO_ACTIVE_SESSION`. * with this change: `SparkConnectException` `NO_ACTIVE_SESSION`, then `SparkConnectException` `NO_ACTIVE_SESSION`. ### Does this PR introduce _any_ user-facing change? Yes. The first call after the server-side session changed raises `NO_ACTIVE_SESSION`, as PySpark does, instead of `INVALID_HANDLE.SESSION_CHANGED`. A session-changed error without an `errorId` is unchanged, as in PySpark. ### How was this patch tested? The assertion of `test_server_session_id_is_observed_and_a_changed_one_closes_the_session_as_pyspark` in `python/tests/test_dropin_e2e.py` now expects `NO_ACTIVE_SESSION`. A new test in `crates/spark-connect-core/tests/server_session.rs` (a loopback service that fails a call with `INVALID_HANDLE.SESSION_CHANGED` and an `errorId`); it fails without the change. `cargo test -p apache-spark-connect --release --lib` (599 passed) and `-p apache-spark-connect-core --release` pass, all tests build with and without `wasm-udf`, and `cargo fmt --all --check` and `ruff check` pass. The offline Python suites (3114 passed, 8 skipped) and the live ones against an OSS Spark 4.3.0 Connect server (281 passed, 1 skipped) pass. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 and Claude Sonnet 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]
