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

   ### What changes were proposed in this pull request?
   
   
`test_i_a_dropped_client_of_a_session_of_its_own_cleans_its_ml_cache_at_exit` 
of `python/tests/test_exit_cleanup_offline.py` runs a child that keeps its 
session and drops a client of a session of its own (of 
`SparkConnectClient(remote)`, `spark.client.newSession()` or 
`spark.client.clone()`), and checks that the dropped client's exit hook sends 
its clean_cache. The child printed only the ID of the session that it keeps. So 
the test took the session of the dropped client to be the one other session 
among all the requests that the mock server recorded, and asserted that there 
were exactly two sessions. A request of any other session that reached the 
server during the test failed it, with three sessions instead of two. That 
happened once, in a run of the offline suite of `coverage.yml`:
   
   ```
   tests/test_exit_cleanup_offline.py:284: AssertionError
   >       assert len(session_ids) == 2 and session_id in session_ids
   E       AssertionError: assert (3 == 2)
   ```
   
   Another session's request does reach a mock server. The mock server listens 
on an ephemeral port of 127.0.0.1. The client retries a request whose server is 
gone under its retry policy, and the release of an execution is retried in the 
background, whether or not the client is closed (`spawn_release` of 
`crates/spark-connect-core/src/client.rs`, as PySpark's). So when a test's 
server stops, the retried requests of its sessions keep going to its port, and 
they reach whichever later server takes that port. This holds within a process 
and across processes, such as the offline suites of other trees that run on the 
same machine.
   
   The child now prints the ID of the session of the client that it drops, as 
it already prints its own. The test checks the requests of those two sessions 
with `_exit_requests`, as the other tests of the file do, and 
`_session_ids_of_requests` goes away. The test also checks that the session 
that the child keeps sends its own clean_cache.
   
   ### Why are the changes needed?
   
   The test failed on a request of a session that is not the child's, which 
neither the child nor the code under test sends. The code is right: under load 
alone, the test does not fail (see below).
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Test only.
   
   ### How was this patch tested?
   
   On master 682c3014, by scripts that run the test function of the file 
against mock servers of `_mock_connect_server.py`:
   
   - **Under load only**, 48 copies at once of the test's three modes, 20 
rounds each, at a load average of up to 58 on 32 cores: master 0 failures of 
2880 runs, this change 0 of 2340 runs (39 of the 48 copies ran; 9 could not 
start their mock server within its 20 seconds under that load). So the child 
sends what the test expects. The failure needs a request of another session.
   - **Another process's retried requests**, on a port that the test's server 
takes: a process runs executions of its session on a mock server of a port P, 
on 64 threads, and stops that server while they run. Its retried requests 
(ReleaseExecute, ExecutePlan and Config) go on to port P. Then the test's 
server takes port P, and the test runs its three modes 10 times, for 3 ports, a 
new one each time (90 runs), and 2 more ports of 16 threads (60 runs). Master 
failed in exactly the runs that such a request reached, 6 of 150. This change 
passed all 150, 7 of them reached by such a request.
   - **Another session that sends requests to the test's server all along**: 
master failed 30 of 30 runs, this change 0 of 30. Before SPARK-62072 (#880, 
master 3857dae9), master failed 30 of 30 too. The assertion came with 
SPARK-61953 (3f743c32), so the flake predates #880, which did not change this 
test.
   - **The test still fails when the dropped client sends no clean_cache at 
exit**: with a child that closes the client before it exits, the test fails in 
each of 2 runs of `client_dropped`.
   - `test_exit_cleanup_offline.py`: 26 passed.
   - The gates: `cargo build -p pyspark-rs --release`; ruff 0.14.0 `check` and 
`format --check`, `test_ruff_excludes.py` and `audit_no_stubs.sh`; 
`gen_type_stubs.py --check` and `gen_fn_dispatch.py --check`; the guards; 
`test_type_stubs_offline.py` (14 passed, 4 skipped); and the offline suite of 
`coverage.yml` (6797 passed, 77 skipped).
   
   ### 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