Repository navigation
integration: deflake TestFailFastWhenConnectShim - #13471
Merged
mxpv merged 1 commit intoMay 30, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR deflakes the Unix shim dial integration test by making shutdown and post-shutdown dial behavior more robust under high-load CI conditions, where closing a Unix socket listener may not immediately yield ECONNREFUSED on subsequent dials.
Changes:
- Adds a polling helper to wait until dials reliably return
ECONNREFUSEDafter shutting down the ttrpc server. - Uses a bounded timeout context for
ttrpcSrv.Shutdownand removes the immediate manual listener close in favor of shutdown-driven closure. - Switches to
testify/requireassertions for the new shutdown/polling checks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
In high-load CI environments, TestFailFastWhenConnectShim/normal-unix-socket-v2 flaked with: expected error connection refused, but got <nil> at shim_dial_unix_test.go:134. Diagnosis: For normal Unix sockets (filesystem-backed, where SetUnlinkOnClose(false) is called to keep the socket file), closing the socket listener does not guarantee that subsequent dials instantly fail with ECONNREFUSED in the OS kernel. Under high parallel contention, the kernel-side transition of the socket file structure to the refusing state is deferred for a brief window. The test immediately dials the address after close, which unexpectedly succeeds under load, flaking the test. Reproduction: We successfully reproduced the flake inside an almalinux/9 Vagrant VM (running with nested virtualization inside a GCE VM) under parallel load, where the test failed exactly on iteration 3 of the integration suite loop. Solution: 1. Remove manual listener.Close() and rely entirely on ttrpcSrv.Shutdown(ctx) to close the listener, preventing double-close races. 2. Use a 5-second timeout context for Shutdown to prevent CI hangs if a connection leaks. 3. Implement a robust 2-second polling helper pollECONNREFUSED inside the test that dials in a 10ms loop (using a 100ms dial timeout to avoid blocking) until it receives syscall.ECONNREFUSED. 4. Assert require.NoError(t, pollECONNREFUSED(addr)) immediately after Shutdown to ensure the OS has fully unlinked/closed the socket before running the main assertions. Tested: Verified by executing 15 parallel integration test runs inside the preserved AlmaLinux 9 Vagrant guest VM. All 15 runs passed successfully (100% success rate). Assisted-by: Antigravity Signed-off-by: Samuel Karp <[email protected]>
samuelkarp
force-pushed
the
deflake-TestFailFastWhenConnectShim
branch
from
May 22, 2026 20:15
d98974f to
a9fba66
Compare
Member
Author
|
mxpv
reviewed
May 22, 2026
cpuguy83
approved these changes
May 30, 2026
mxpv
approved these changes
May 30, 2026
This was referenced Sep 15, 2026
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.
In high-load CI environments,
TestFailFastWhenConnectShim/normal-unix-socket-v2 flaked with:
expected error connection refused, but got <nil>at shim_dial_unix_test.go:134.
Diagnosis:
For normal Unix sockets (filesystem-backed, where
SetUnlinkOnClose(false) is called to keep the socket file), closing the socket listener does not guarantee that subsequent dials instantly fail with ECONNREFUSED in the OS kernel. Under high parallel contention, the kernel-side transition of the socket file structure to the refusing state is deferred for a brief window. The test immediately dials the address after close, which unexpectedly succeeds under load, flaking the test.
Reproduction:
We successfully reproduced the flake inside an almalinux/9 Vagrant VM (running with nested virtualization inside a GCE VM) under parallel load, where the test failed exactly on iteration 3 of the integration suite loop.
Solution:
Tested:
Verified by executing 15 parallel integration test runs inside the preserved AlmaLinux 9 Vagrant guest VM. All 15 runs passed successfully (100% success rate).
Assisted-by: Antigravity