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

   ### What changes were proposed in this pull request?
   
   This is a follow-up of #657 (SPARK-61773), which bounded a connection 
through an HTTP proxy as a whole by grpcio's 20 s connect deadline. That bound 
covers the TCP connection to the proxy, the tunnel, and the TLS handshake 
inside it. #657 left the direct path unchanged, with the same pre-existing gap 
("tonic's `connect_lazy` bounds only the TCP connection, which belongs in a 
follow-up because it changes behavior for every user"). This is that follow-up.
   
   The direct channel is now built like the proxied one: 
`connect_with_connector_lazy` with tonic's own HTTP connector. Under it, tonic 
bounds the whole connector, so the TLS handshake is included in 
`connect_timeout`.
   - The connector is configured as tonic's `Endpoint::http_connector` 
configures it for this endpoint: `enforce_http(false)`, so that an `https` URI 
goes through it, and `TCP_NODELAY`.
   - The TCP connection keeps its 10 s bound (`READY_TIMEOUT`), as before.
   - The whole connection now has 20 s (`CONNECT_TIMEOUT`, renamed from 
`PROXY_CONNECT_TIMEOUT`, as both paths use it).
   - A timeout is tonic's `UNKNOWN` of an I/O `TimedOut`. `grpc_python_code` 
already reports it as `UNAVAILABLE`, as grpc-python does, and the retry policy 
retries it.
   
   `hyper-util` gains its `client-legacy` feature, which tonic's `channel` 
feature already enables, so `Cargo.lock` does not change. 
`docs/compatibility.md` describes the bound and the one difference that remains.
   
   ### Why are the changes needed?
   
   A server, or a middlebox, that accepts the TCP connection and never answers 
the TLS handshake held the call until its own deadline. For a `spark.conf.get` 
against such a server:
   
   | | PySpark 4.3.0 (grpcio 1.85.1) | before |
   |---|---|---|
   | the connection | dropped after 20.0 s | never closed |
   | the error | `UNAVAILABLE` "Handshake read failed", retried by the policy | 
`Deadline Exceeded` after 600 s, the deadline of the Config request |
   
   The process's exit then waited on the same stalled connection too, since the 
exit's `clean_cache` uses it.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as grpcio behaves. A direct TLS connection whose TCP connection and 
handshake take more than 20 s now fails with `UNAVAILABLE` and is retried, 
instead of waiting for the deadline of the call. A plaintext connection is 
unchanged.
   
   One difference remains, documented: grpcio also waits at most 20 s for the 
server's HTTP/2 settings. Here, a plaintext connection to a server that accepts 
it and never answers ends at the keepalive of the connection (80 s by default), 
or at the deadline of the call without a keepalive.
   
   ### How was this patch tested?
   
   - New `a_tls_handshake_that_stalls_on_a_direct_connection_is_unavailable` in 
`crates/spark-connect-core/tests/proxy.rs`, the direct-path twin of the 
stalled-TLS proxy test. A loopback server accepts the TCP connection and never 
answers. The call fails with `UNAVAILABLE` after more than 15 s and within the 
40 s bound of the test, after one connection. Without the change, the test 
fails at its 40 s bound.
   - `cargo test -p apache-spark-connect-core --release`: 234 unit tests and 
the integration tests pass, including the 15 proxy tests.
   - The core's live `integration_test -- --ignored` passes against a Spark 
4.3.0 Connect server.
   - `cargo fmt --all --check` and `cargo +1.100.0 clippy -p 
apache-spark-connect-core --all-targets -- -D warnings`.
   
   ### 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