Skip to content

Wait for the Agent's greeting to end before two server tests count statements or hang up - #295

Merged
gccody merged 1 commit into
mainfrom
fix/monitor-greeting-count-race
Nov 20, 2026
Merged

gccody merged 1 commit into
mainfrom
fix/monitor-greeting-count-race

Conversation

@gccody

@gccody gccody commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Two server tests raced the Agent connection's own greeting. They are the only server tests that failed a first attempt in CI over the last 200 runs, and one of them failed the 0.5.0 release run.

a_reconnecting_agent_is_told_what_the_server_holds (4 failures, 3 of them on 2026-11-20) counted the statements of monitors::greeting right after reading set_monitors from the socket. The connection's task reads the device once more after sending that (updates::publish_device at the end of greet), and under load that read landed in the count: (5, 0) instead of (4, 0), on either backend.

an_agent_that_goes_offline_to_update_shows_as_updating (2 failures, 2026-11-10 and 11-11) said it was updating and hung up 100–200 ms later. A connection that is still greeting when the socket closes fails a send and never enters the loop that reads what the Agent said, so the device showed as offline (updating_to null) instead of updating.

Both now wait for the last message of the greeting first, through a new common::greeted (the thumbnail interval is the last thing a new connection is sent). Test-only; the server is unchanged.

How it was checked. Looping the unfixed monitors test alone 55 times never failed, so the race needs the whole binary's load. To prove the cause, a scratch server build (not in this PR) ran 300 reads 1 ms apart just before publish_device:

Tests monitors test realtime test
as on main 0 of 5 passed, (5, 0) vs (4, 0) 0 of 5 passed, Null vs "1.2.3"
with this PR 5 of 5 passed 5 of 5 passed

Those are the CI failures' exact messages. cargo fmt --check passes; the server suite's full run is CI's.

…atements or hang up

Two server tests raced the connection's own greeting and failed in CI about every other run:

- a_reconnecting_agent_is_told_what_the_server_holds counted the statements of monitors::greeting right after reading set_monitors from the socket. The connection's task reads the device once more after sending that (updates::publish_device), and that read landed in the count: 5 statements instead of 4.
- an_agent_that_goes_offline_to_update_shows_as_updating said it was updating and hung up 100 ms later. A connection that is still greeting when the socket closes fails a send and never reads what the Agent said, so the device showed as offline instead of updating.

Both now wait for the last message of the greeting (common::greeted) first.
@gccody
gccody enabled auto-merge (squash) November 20, 2026 17:36
@gccody
gccody merged commit 6f1ee46 into main Nov 20, 2026
9 checks passed
@gccody
gccody deleted the fix/monitor-greeting-count-race branch November 20, 2026 17:49
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