Skip to content

net/stream: time the redial test against its own clock - #423

Merged
jamesbraid merged 1 commit into
techomancer:mainfrom
jamesbraid:test-retry-rate-flake
Nov 4, 2026
Merged

jamesbraid merged 1 commit into
techomancer:mainfrom
jamesbraid:test-retry-rate-flake

Conversation

@jamesbraid

Copy link
Copy Markdown
Collaborator

a_peer_that_hangs_up_is_redialled_at_the_retry_rate checks that a peer that accepts and hangs up is redialled once per retry interval, not in a tight loop.

It counted accepts in a fixed one-second window and wanted 5 to 15. On a loaded host the backend thread can sit descheduled for part of that window, so it dialled fewer times and the test failed once with "3 connections in one second". It passes alone.

The test now waits for six accepts and checks the time between the first and the last. The backend can be late but can't dial sooner than one retry after the previous dial, so that span has a floor load doesn't move. The only slack needed is for the first accept being noticed late, and the test allows it one interval. Test only, no change to the backend.

It still catches a broken delay: removing the wait after a hung-up session fails it with "6 connections in 49ms, expected at least 400ms".

200 sequential runs of the fixed test: 200 passes.

a_peer_that_hangs_up_is_redialled_at_the_retry_rate counted accepts in
a fixed one-second wall-clock window and asserted 5 to 15 of them. When
the host was loaded the backend thread could be descheduled for part of
that window, so it dialled fewer times than the interval allows and the
test failed with "3 connections in one second".

Wait for six accepts instead and check the time between the first and
the last. The backend can be late but cannot dial sooner than one retry
after the previous dial, so the span has a floor that load does not
move. The only slack needed is for the first accept being noticed late,
which the test allows one whole interval. A client that redials without
waiting makes the six in a few milliseconds and fails.

Checked by dropping the wait after a hung-up session: the test fails
with six connections in 49ms. 200 sequential runs of the fixed test
pass.
@jamesbraid
jamesbraid merged commit 3bcde9f into techomancer:main Nov 4, 2026
7 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.

1 participant