HyukjinKwon opened a new pull request, #905:
URL: https://github.com/apache/spark-connect-rust/pull/905
### What changes were proposed in this pull request?
The Rust transport of the Python client (`pyspark-client-rust`) connected,
retried and reported failures as tonic does, where pyspark-client's grpcio
follows gRPC core. This closes the differences that
`dev/parity/known-differences.md` listed for them, in the grpcio dialect of the
Python client. The Rust API keeps its own behavior, as the 4.4 Rust migration
notes list.
- **Connections:**
- A channel races the addresses of its host 250 ms apart, fails fast and
backs off as gRPC's channel does, of grpcio's texts of a failure ("failed to
connect to all addresses; last error: ...").
- Sessions share one connection per target, as grpcio's channels do; a
session of a token has its own.
- The HTTP/2 connection window is gRPC's, so one session cannot starve the
others.
- The trust store of TLS is `GRPC_DEFAULT_SSL_ROOTS_FILE_PATH` where it is
set, else the system's and grpcio's `roots.pem`. TLS sessions are not resumed,
as grpcio's are not.
- **Retries:** `set_retry_policies` takes any policy, of its own `can_retry`
and `to_state`, which PySpark's `Retrying` asks of each call on the failure
path. Requests sent in the background warn `RETRIES_EXCEEDED` as PySpark's do.
The logs of the transport are grpcio's, in grpcio's order.
- **Errors left to grpc:** the clone, `copy_from_local_to_fs` and the
caching of artifacts raise grpcio's `RpcError` where grpcio is installed. The
clone asks for nothing more of its failure in either dialect.
- **grpcio's codes and texts:**
- A response that does not decode gives "Exception deserializing
response!", of no `debug_error_string`.
- A message over 128 MiB, either way, gives `RESOURCE_EXHAUSTED` of
"Received message larger than max" or "Sent message larger than max".
- Response metadata past gRPC core's limits fails as gRPC core does, of
its listing. The client advertises grpcio's limit of a header list, so Spark's
server resets such a stream, as for grpcio, and a stream that the server resets
gives "Stream removed (RST_STREAM ...)" of gRPC core's code. Metadata of
hundreds of KB no longer hangs the client.
- A status whose details do not match it raises the `ValueError` of
`grpc_status.rpc_status.from_call`, where PySpark calls it.
- The query-context logger prints grpcio's exception of the call.
- **Forks:** a child of `os.fork()` closes the parent's connections and the
descriptors of its runtime, and can use and free inherited sessions without
affecting the parent. New `fork` module of the core.
### Why are the changes needed?
To close these differences from PySpark (the known-differences review).
### Does this PR introduce _any_ user-facing change?
Yes: the connections, retries, logs and errors above are grpcio's. What
remains is documented in `docs/compatibility.md` and
`dev/parity/known-differences.md`:
- `channelOptions` such as `grpc.max_metadata_size` are not configurable;
- a converted exception has no `__context__`;
- a few corners of the children of a fork and of the metadata of a gRPC-core
server.
### How was this patch tested?
- New tests in the core crates (connector, fork, metadata, retries;
certificates generated at test time) and in
`python/tests/test_dropin_offline.py` and `test_dropin_e2e.py`, which fail
without the changes. The core tests pass in parallel runs in debug and release.
- Eight rounds of an independent review that compared the drop-in with
PySpark 4.3.0 (grpcio 1.85) through probes. It covered:
- fake gRPC and raw HTTP/2 servers that refuse, reset, garble or oversize
their responses;
- Spark's own server, of real errors of CJK messages;
- TLS, fork and multiprocessing, retry policies, logs and their order;
- performance.
Every finding was fixed or documented.
- The core tests (release and debug), wasm, clippy, rustdoc, the stubs, the
licenses, the native server's crates and inventory, the offline suite in sorted
order and under coverage, and the live e2e with and without protobuf.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code
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]