HyukjinKwon opened a new pull request, #843:
URL: https://github.com/apache/spark-connect-rust/pull/843
### What changes were proposed in this pull request?
A follow-up of #802 (SPARK-61915), from a round-3 review of the transport
against pyspark-client 4.3.0 (grpcio 1.85.1). Each item was probed on both
clients through recording proxies and grpc abort servers.
**1. PySpark's `[RETRIES_EXCEEDED]` warning.**
- PySpark warns with a UserWarning when the retries of a request are spent
(connect/client/retries.py:280-287, 309-312). The drop-in never warned, as the
core's retry loop did not tell a failure that is not retryable from retries
that ran out.
- The core now does: `Backoff::Exceeded` and `RetryError::Exceeded`, and a
`RetryPolicy::retries_failures` field, false when no policy retries. A
process-wide listener is told where PySpark's `_wait` warns: when a call's
retries are spent, and when the retry-at-once path of `RetryException` runs
past its elapsed-time bound.
- The binding emits PySpark's warning there, at PySpark's location
(`retries.py`) and module, from the Python thread of the call. So
`simplefilter("error")` raises it instead of the failure, as in PySpark, with
`_operation_id` on executions.
- With the server down and `DefaultPolicy(max_retries=1)`, both clients warn
on count (twice), conf.get, schema, interruptAll, sql, version and stop.
**2. `stop()`'s release failure** is logged through the vendored connect
logger, as PySpark's (connect/session.py:949-953), which is silent unless
`SPARK_CONNECT_LOG_LEVEL` is set. It went to `logging.getLogger("pyspark")`,
which reaches stderr through logging's lastResort.
**3. The text of a gRPC failure without status details** is grpcio's, as
PySpark's `str(e)` (core.py:2408-2418, 2456-2459): `<_InactiveRpcError of RPC
that terminated with: status = StatusCode.X, details = "...",
debug_error_string = "X:details">`. It was tonic's, `[The service is currently
unavailable] tcp connect error`. A status from the server gives byte-identical
text on both clients. The Rust API keeps its message: the core gives grpcio's
text, which names Python classes, only in a doc-hidden
`SparkError::pyspark_message`, which the Python binding raises.
**4. PySpark's requests for the first command and for the registrations.**
- A command's request is built before the plan compression lookup, as
PySpark's `execute_command` (core.py:1416, 1518-1527, 2714-2736). So the first
command of a session, such as `sql`, `createOrReplaceTempView` or `write.save`,
does not carry `client_observed_server_side_session_id`.
- The udf, udtf, data-source and Java-function registrations are sent as
they are: no compression and no Config lookup, as PySpark sets
`req.plan.command` directly (core.py:1111-1185). An 11 MB UDF registration was
compressed, and the first registration of a session sent a Config request that
PySpark does not.
**5. The stack-trace conf** read while raising a server error retries under
the client's policy, as PySpark's `config()` (core.py:2071-2080).
**6. Docs.**
- The user agent of `newSession` and `cloneSession` (the parent's), where
PySpark reads the environment variable at each request.
- The errors that `copyFromLocalToFs` and `cloneSession` convert, where
PySpark leaves grpc's `RpcError`.
`docs/compatibility.md` and `dev/parity/known-differences.md` describe
these, with two remaining differences:
- the requests sent in the background (ReleaseExecute, checkpoint and ML
releases, the interrupt of a signal) do not warn, as their threads are not
Python's;
- the details of a failure that the client itself detects, such as a refused
connection, are tonic's, not gRPC C-core's.
### Why are the changes needed?
So that warnings, logs, error texts and requests are PySpark's, for code
that filters warnings, parses errors or compares requests.
### Does this PR introduce _any_ user-facing change?
Yes, as above. In the Rust API:
- `RetryPolicy` has a new public field, so a struct expression that names
every field must add it;
- a process-wide retry listener can be set;
- `SparkConnectClient::execute_plan_reattachable_uncompressed` and
`SparkError::from_grpc_status_of` are added;
- `SparkError` has a doc-hidden field, `pyspark_message`. The messages of
the Rust API's errors do not change.
These are in the Rust migration notes.
### How was this patch tested?
- **New tests.**
- `test_dropin_offline.py`:
- `test_spent_retries_warn_where_pyspark_warns`;
-
`test_the_message_of_a_grpc_error_without_details_is_the_text_of_grpcio_as_pyspark`;
-
`test_registrations_are_sent_as_they_are_without_the_lookup_as_pyspark`.
- Core tests:
- of the listener on spent policy retries and on the `RetryException`
bound;
- of the first command's observed session ID;
- of the uncompressed path;
- of `Exceeded` against `GiveUp`;
- of grpcio's text.
- **Probes of both clients:**
- the warnings, their counts, locations and filters;
- the logs;
- the error texts;
- the request sequences of sql, temp views, writes, collects, udf, udtf,
data sources and Java functions.
- **Rust.**
- `cargo test -p apache-spark-connect -p apache-spark-connect-core
--release`, and `--features wasm-udf`;
- the live `integration_test`, `e2e_integration`, `e2e_session_catalog`
and `e2e_reattach_drop`;
- `cargo test -p pyspark-rs --lib`, linked as `rust.yml` links it.
- **Python.**
- The offline suite of `coverage.yml` on pandas 2 and 3.
- Live `test_dropin_e2e.py` and `test_arrow_e2e.py`.
- The type-stub drift check and test, with mypy and pyright.
- **Lint.**
- `cargo fmt --all --check`, `cargo +1.100.0 clippy -p pyspark-rs -p
apache-spark-connect -p apache-spark-connect-core --all-targets -- -D
warnings`, ruff 0.14.0, `audit_no_stubs.sh` and `scripts/tests`;
- `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps`.
### 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]