Skip to content

fix flaky TCPPeer test - #5488

Merged
dmkozh merged 1 commit into
stellar:masterfrom
graydon:flaky-tcp-test
Oct 22, 2026
Merged

dmkozh merged 1 commit into
stellar:masterfrom
graydon:flaky-tcp-test

Conversation

@graydon

@graydon graydon commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Test has been failing recently with

stellar-core/src/overlay/test/TCPPeerTests.cpp:617: FAILED:
	  REQUIRE( msgWrite.count() == prevMsgWrite + 2 )
	with expansion:
	  6 == 5

this fixes two potential causes (SCP firing and pings firing). confirmed with a bunch of running-in-a-loop with different prng seeds and varying forced delays, which is about the best one can do.

@sisuresh

Copy link
Copy Markdown
Contributor

Claude flagged a possible remaining race. GET_TX_SET is posted to the SCPQ scheduler queue and ERROR to CTRL (Peer::recvAuthenticatedMessage). The scheduler picks between queues by accumulated service time, not arrival order, so ERROR can run first. If it does, recvError drops p1, the queued GET_TX_SET hits shouldAbort before its timer is recorded, and the prevGetTxSet + 1 check fails. It also noted that the FORCE_SCP comment still says the test counts p0's writes.

@graydon

graydon commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Claude flagged a possible remaining race. GET_TX_SET is posted to the SCPQ scheduler queue and ERROR to CTRL (Peer::recvAuthenticatedMessage). The scheduler picks between queues by accumulated service time, not arrival order, so ERROR can run first. If it does, recvError drops p1, the queued GET_TX_SET hits shouldAbort before its timer is recorded, and the prevGetTxSet + 1 check fails. It also noted that the FORCE_SCP comment still says the test counts p0's writes.

fixed

@graydon
graydon marked this pull request as ready for review October 20, 2026 02:36
@graydon
graydon requested review from anupsdf and a balanced review from Copilot October 20, 2026 02:36

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.

🟢 Approval recommended

The focused test-only changes address the reported races while preserving communication checks, with no unresolved findings.

No open issues 🎉

What changed in this PR

Stabilizes the TCPPeer communication test by isolating its assertions from unrelated background traffic.

Changes:

  • Disables forced SCP and stops overlay ticks before authentication.
  • Replaces aggregate write counts with message-specific counters and verifies ERROR delivery.
File Description
src/​overlay/​test/​TCPPeerTests.cpp Removes traffic-related assertion races without changing production code.

Review effort: Balanced

@dmkozh
dmkozh added this pull request to the merge queue Oct 22, 2026
Merged via the queue into stellar:master with commit 05c6328 Oct 22, 2026
58 of 59 checks 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.

5 participants