HyukjinKwon opened a new pull request, #864:
URL: https://github.com/apache/spark-connect-rust/pull/864

   ### What changes were proposed in this pull request?
   
   From a review of the documented differences of the transport against PySpark 
4.3.0 (grpcio 1.85.1). Each item was probed on both clients, with silent 
sockets, proxies and TLS roots files.
   
   **1. An invalid proxy address does not fail the hosts that the proxy does 
not apply to.**
   - With an invalid `grpc_proxy` (such as `http://localhost:80837`, 
`p:notaport`, `[::1`) and a host that `no_proxy` or `no_grpc_proxy` excludes, 
grpcio connects directly, where the drop-in failed `create()` with `Invalid 
HTTP proxy address`.
   - `ProxyEnv::proxy_for` now parses the proxy URI first, and fails an invalid 
address only for a host that the proxy applies to. Loopback and `no_proxy` 
hosts connect directly.
   - For the other hosts, the drop-in keeps its error at `create()`, where 
grpcio makes the session and fails its first request with UNAVAILABLE; this is 
documented with its reason.
   
   **2. A server that sends no HTTP/2 settings fails within the connect 
deadline.**
   - Against a server that accepts the connection and never answers, PySpark 
fails at 20.3 s: grpcio waits for the server's SETTINGS within its connect 
deadline. The drop-in waited for the keepalive, 80 s, and its first plan, the 
lookup of the plan compression and then the execution, 160 s.
   - A plaintext connection's stream (`ServerStream`, of a new 
`DirectConnector` and of the proxy tunnel) fails a read once the connect 
deadline, 20 s from the connector call, passes before the server's first frame 
has arrived, with grpcio's details: `connection attempt timed out before 
receiving SETTINGS frame`. The call fails with UNAVAILABLE.
   - The stream does not peek before the client's preface: a server that waits 
for the preface, or sends its SETTINGS late within the deadline, still connects 
(tests at 12 s, and after the preface).
   - What remains, documented with its reason: grpcio keeps a channel failed 
until a connection succeeds, so its later calls fail at once, and its first 
plan at 20.3 s. The drop-in reconnects for each call, so its first plan fails 
at 40 s. TLS connections have no such bound after their handshake, as tonic 
does TLS above the connector.
   
   **3. grpcio's errors of the proxy and the TLS roots reach stderr**, as 
grpcio's C core writes them, unless `GRPC_VERBOSITY` is `NONE`.
   - A proxy URI that is not a proxy: grpcio writes `E1118 16:53:41.241267 
4026384 http_proxy_mapper.cc:159] 'https' scheme not supported in proxy URI` of 
each channel. A TLS roots file that cannot be read gets `error loading file`, 
once per process.
   - The drop-in sent them to Rust's `tracing`, which the Python client never 
shows.
   - A new `grpc_log` module of the core gives them to a listener that the 
Python binding sets at import, as `retries::set_listener` does. The binding 
writes grpcio's line format to stderr, of the Python thread of the call.
   - `GRPC_DEFAULT_SSL_ROOTS_FILE_PATH` and its file are now read once per 
process, as grpcio reads them, and an empty file is silent, as in grpcio.
   
   **4. Docs.**
   - `docs/configuration.md`: the invalid proxy with its reason, non-UTF-8 
values, the TLS roots read once (and the reason for the system store: an empty 
store fails), and a new "Errors on stderr" section.
   - `docs/compatibility.md`: the proxy and connect-deadline paragraphs, the 
user agent's read time with its reason, and the SETTINGS details.
   - `dev/parity/known-differences.md`: the remaining fail-fast difference. N6: 
the CONNECT request has no `User-Agent`, where grpcio sends `grpc-httpcli/0.0`, 
and PySpark's debug logs of `SPARK_CONNECT_LOG_LEVEL=debug` (RPC deadlines, 
"Given up on retrying", "GRPC Error received").
   
   ### Why are the changes needed?
   
   So that a bad proxy variable does not break the hosts it does not apply to, 
so that a silent server fails in tens of seconds rather than minutes, and so 
that grpcio's diagnostics are visible, as with PySpark.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as above. In the Rust API:
   - a new `grpc_log` module (a listener of these errors, not a stable API);
   - the roots file is read once per process;
   - a silent plaintext server fails its connection at the connect deadline.
   
   ### How was this patch tested?
   
   - **New tests.**
     - `crates/spark-connect-core/tests/proxy.rs`: an invalid proxy with 
`no_proxy` and `no_grpc_proxy` hosts connects directly; a silent server, 
directly and in a stalled tunnel, fails with the SETTINGS text after at least 
15 s and within 40 s; servers that send their SETTINGS at 12 s, or only after 
the client's preface, connect.
     - Unit tests in `proxy.rs`, `client.rs` and `grpc_log.rs`.
     - `test_dropin_offline.py`: the format and the thread of the stderr line, 
one line per connected session, and silence with `GRPC_VERBOSITY=none` in a 
fresh process.
   - **Probes of both clients:**
     - the proxy matrix (seven invalid formats, with and without `no_proxy`);
     - silent sockets, direct and through a tunnel: grpcio 20.3 s / 20.0 s, the 
drop-in 20.0 s for a call, and 40 s for a first plan, against 160 s before;
     - the stderr lines, their counts per channel and `GRPC_VERBOSITY`;
     - TLS roots files.
   - **Rust.** `cargo test -p apache-spark-connect -p apache-spark-connect-core 
--release` (1713 passed), and `--features wasm-udf` (1395), and in a debug 
build (1713); `cargo test -p pyspark-rs --lib`, linked as `rust.yml` links it. 
Live: the core `integration_test`, `e2e_integration`, `e2e_dataframe`.
   - **Python.** The offline suite of `coverage.yml` in its order, on pandas 3 
and a UTC host without `TZ=UTC` (6401 passed). Live `test_dropin_e2e.py`.
   - **Lint.** `cargo fmt --all --check`, `cargo +1.100.0 clippy --all-targets 
-- -D warnings`, ruff 0.14.0, `audit_no_stubs.sh`, `scripts/tests` and 
`RUSTDOCFLAGS="-D warnings" cargo doc --no-deps` with wasm-udf.
   
   ### 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]

Reply via email to