Skip to content

Wait for every held message before closing in the resume-order test - #102

Merged
kahrendt merged 2 commits into
mainfrom
claude/nice-newton-2083bc
Oct 28, 2026
Merged

kahrendt merged 2 commits into
mainfrom
claude/nice-newton-2083bc

Conversation

@kahrendt

Copy link
Copy Markdown
Contributor

Summary

TransportTest.HeldBackConnectionsResumeInTheOrderTheyWereHeld was flaky. It failed on the Linux TSan job of #100 with order holding only the five "first" messages. The test raced the network thread in two places. This PR changes only the test.

Change

  • The first connection's close. The first connection's close is raised outside the inbound ring's room, so it can reach core while later connections are still parked. The test then closed them and their messages never arrived. It now also waits until every expected message has been delivered before closing the later connections.
  • The last later message. wait_taken() shows the kernel bytes were read, not that the push was refused. The last later message could therefore be pushed once core freed room, ahead of the parked ones (order showed "later 8" before the first's held message). A probe connection that core closes after that message is taken now ends only after the network thread has pushed it. The test waits for that before core runs.

Tests

  • No new tests.
  • Swapping two entries of the expected order still fails the assertion.
  • Known gap: the stress runs were on macOS; the original failure was on Linux.

TransportTest.HeldBackConnectionsResumeInTheOrderTheyWereHeld raced the
network thread in two places:

- The first connection's close is raised outside the inbound ring's
  room, so it could reach core while later connections were still
  parked. The test then closed them and their messages never arrived.
  It now also waits until every expected message has been delivered.
- wait_taken() shows that the kernel bytes were read, not that the push
  was refused. The last later message could therefore be pushed once
  core freed room, ahead of the parked ones. A probe connection that
  core closes after that message is taken now ends only after the
  network thread has pushed it.

Under loaded TSan runs on macOS the test failed 26 times in 900 before
this change and 0 times in 1800 after it.
@kahrendt
kahrendt requested a balanced review from Copilot October 28, 2026 12:25
@kahrendt
kahrendt marked this pull request as ready for review October 28, 2026 12:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The synchronization probe is declared const, but its completion handler later modifies non-mutable members, causing undefined behavior in the new synchronization path.

1 open issue
What changed in this PR

This test-only PR addresses two races in the transport resume-order test that caused intermittent failures during Linux ThreadSanitizer testing.

Changes:

  • Adds a probe connection to synchronize the final held-message push before core drains the inbound ring.
  • Waits for every expected message before closing the remaining connections.
  • Checks probe completion and errors alongside the existing peers.
File Description
tests/​test_transport.cpp Strengthens synchronization and shutdown conditions in the held-message resume-order test.

Review effort: Balanced

Comment thread tests/test_transport.cpp Outdated
The peer's completion handler assigns its members after construction,
which a const object does not allow.
@kahrendt
kahrendt merged commit 0b6a3e9 into main Oct 28, 2026
13 checks passed
@kahrendt
kahrendt deleted the claude/nice-newton-2083bc branch October 28, 2026 12:54
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.

2 participants