test(engine): wait for every client before counting accepts in the #662 queued-accept rig - #680
Merged
Merged
Conversation
… queued-accept rig runPauseQueued662 (epoll and io_uring) asserted AcceptCount == blockers + queued right after the queued connections answered. A blocker that landed on a loop already held sits in that loop's accept queue until the loop comes back, and nothing orders its accept before the queued connections' responses: when every queued connection hashes to another loop, all of them can answer first and the count reads one short. It happened once on main's Unit job (c4d1cb5, epoll, the control arm): "AcceptCount = 10, want 11", accepts before release 2, blockers 3, and 11 after the clients closed. Both copies now read every blocker's response too (still unscored) before reading the metrics. A response exists only after its connection was accepted and counted (the counter is an atomic add at accept time in both engines), so the count check is exact with no polling.
Each epoll loop skips counting its first accept. The fixed queued-accept tests must fail on this commit; the next commit removes it.
Restores engine/epoll/loop.go byte-for-byte to main; the branch now differs from main only in the two test files.
Contributor
Author
|
Proof on the runner, as described above:
This merges once the #657 PR-2 branch has opened its PR. |
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.
Summary
Test-only fix. Main's Unit job went red on c4d1cb5 (run 35428669128) in
engine/epoll:Cause. The rig holds every loop inside a blocking handler.
AcceptCount.The engine is fine; the test raced its own measurement. The io_uring copy of the rig (
engine/iouring/pause_accept_queued_linux_test.go) has the same gap. It cannot trip in CI's one-worker Unit shape, but it can at two workers.Fix. Both copies now also wait for every blocker's response before reading the metrics. The blockers' responses are still unscored. A response exists only after its connection was accepted and counted:
AcceptCountis an atomic add at accept time, atengine/epoll/loop.go:939andengine/iouring/worker.go:1913. So once every client has a response, the check is exact, with no polling and no new timing.Proof, on the runner
The commits go up in order:
engine/epoll/loop.gothat makes each loop skip counting its first accept, the smallest real miscount. CI on this head must fail the two queued-accept tests on the count checks. This shows the fixed test still catches a lost accept.The run links will be added below. The squash merge carries no mutant.
This waits to merge until the #657 PR-2 branch has opened its PR, because both touch
engine/.