Skip to content

xtcp: fix the TestTCPDest_writeTimeout race (poll the drop, not the first write error) - #398

Merged
randomizedcoder merged 1 commit into
mainfrom
xtcp/tcpdest-writetimeout-flake
Dec 5, 2026
Merged

randomizedcoder merged 1 commit into
mainfrom
xtcp/tcpdest-writetimeout-flake

Conversation

@randomizedcoder

Copy link
Copy Markdown
Owner

Fixes the TestTCPDest_writeTimeout flake on main (the one noted in #388).

The race

The test waited for destTCP/Write/error >= 1, then read the dropped counter once. With attempts = 2:

  1. the first write error is counted when the 100 ms deadline fires, which is also when the test's 20 ms poll wakes;
  2. the second attempt fails at once on the closed pipe;
  3. only then is the drop counted.

A poll landing between steps 1 and 3 failed the test: 3 of 20 runs on main, 17 of 300 with -race -cpu 1,2,8.

The fix

The test now waits for the drop, the worker's last step, and then checks one write error per attempt. Test-only change in pkg/xtcp/destinations_tcp_test.go. Passed 300 of 300 runs with -race -cpu 1,2,8.

Gates (at 43ed7dd, rebased on main 4a9a934)

  • go test ./...: 114 packages pass
  • go test -race -count=20 -run TestTCPDest_writeTimeout ./pkg/xtcp/: pass
  • test-go-race: pass
  • lint-baseline (tiers 0-2): pass

🤖 Generated with Claude Code

…error

The test polled destTCP/Write/error >= 1 and then read the dropped
counter once. With attempts = 2 the first write error is counted when
the 100 ms deadline fires (when the test's 20 ms poll also wakes), the
second attempt fails at once on the closed pipe, and only then is the
drop counted, so a poll landing between them failed the test: 3 of 20
runs on main, 17 of 300 with -race -cpu 1,2,8.

It now polls the drop, the worker's last step, and then checks one
write error per attempt. 300 of 300 with -race -cpu 1,2,8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randomizedcoder
randomizedcoder merged commit ebfe27d into main Dec 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant