[SPARK-59701][PYTHON][TESTS] Fix flaky test_reap_server_does_not_expire_when_idle_retirement_is_disabled - #58953
Closed
gaogaotiantian wants to merge 1 commit into
Closed
gaogaotiantian wants to merge 1 commit into
gaogaotiantian wants to merge 1 commit into
Conversation
…n_idle_retirement_is_disabled ### What changes were proposed in this pull request? Give each subtest iteration of `test_reap_server_does_not_expire_when_idle_retirement_is_disabled` its own `_listening_socket()` instead of sharing one listener across both iterations. ### Why are the changes needed? `_listening_socket()` calls `listen(1)` and never accepts. `reap` probes reachability via `_port_open`, which connects and closes without the server ever accepting the connection, so the connection keeps occupying the sole backlog slot. With both iterations sharing one listener, the second iteration's connect could not complete, timed out after 0.5s, and `is_usable()` returned False -- retiring a server that idle retirement was disabled for. This flaked on macOS CI. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing unit test `LocalConnectServerPoolUnitTests`. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Isaac Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Author
|
@ericm-db hey Eric could you take a look at the test fix and see if it's correct? Thanks! |
dongjoon-hyun
approved these changes
Sep 21, 2026
HyukjinKwon
approved these changes
Sep 21, 2026
dongjoon-hyun
pushed a commit
that referenced
this pull request
Sep 22, 2026
…e_when_idle_retirement_is_disabled
### What changes were proposed in this pull request?
Give each subtest iteration of
`test_reap_server_does_not_expire_when_idle_retirement_is_disabled` its own
`_listening_socket()` instead of sharing one listener across both iterations.
### Why are the changes needed?
`_listening_socket()` calls `listen(1)` and never accepts. `reap` probes reachability via `_port_open`, which connects and closes without the server ever accepting the connection, so the completed connection keeps occupying the sole backlog slot. With both iterations sharing one listener, the second iteration's connect could not complete, timed out after 0.5s, and `is_usable()` returned `False` -- retiring a server that idle retirement was disabled for. This flaked on macOS CI (`macos-26-arm64`):
```
FAIL: test_reap_server_does_not_expire_when_idle_retirement_is_disabled (value='-1')
self.assertEqual(set(self._states(uid)), {"server"})
AssertionError: Items in the first set but not the second: 'retired'
```
Scoping a fresh listener per iteration matches the single-connect-per-listener pattern the other tests in this suite already use.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Existing unit test `LocalConnectServerPoolUnitTests` in `pyspark.sql.tests.connect.test_connect_local_server_pool`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Isaac
This pull request and its description were written by Isaac.
Closes #58953 from gaogaotiantian/fix-local-connect-pool-reap-test-flake.
Authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit b5aa3bd)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Give each subtest iteration of
test_reap_server_does_not_expire_when_idle_retirement_is_disabledits own_listening_socket()instead of sharing one listener across both iterations.Why are the changes needed?
_listening_socket()callslisten(1)and never accepts.reapprobes reachability via_port_open, which connects and closes without the server ever accepting the connection, so the completed connection keeps occupying the sole backlog slot. With both iterations sharing one listener, the second iteration's connect could not complete, timed out after 0.5s, andis_usable()returnedFalse-- retiring a server that idle retirement was disabled for. This flaked on macOS CI (macos-26-arm64):Scoping a fresh listener per iteration matches the single-connect-per-listener pattern the other tests in this suite already use.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing unit test
LocalConnectServerPoolUnitTestsinpyspark.sql.tests.connect.test_connect_local_server_pool.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Isaac
This pull request and its description were written by Isaac.