TestIdleCleanupKeepsActiveUser fails on some runs and turns next red #181

Closed
opened 2026-10-21 06:34:32 +02:00 by clawbot · 0 comments
Collaborator

TestIdleCleanupKeepsActiveUser in internal/ircserver/server_test.go fails on some runs, which turns script/cibuild red on next. It failed on ddfbdc1 with cleanup removes [{1 active} {2 idle}], want only idle and passed when the same build reran the suite with -v.

The test registers active and idle, sleeps idleTimeout (500 ms), has active send PING and wait for the PONG, then asks GetStaleOrphanSessions for sessions last seen before now minus 500 ms, and expects only idle. Sometimes active is in the result too. Find out why before changing anything; two readings fit: the session's last-seen time is stored at whole-second precision, so a touch at 12:00:00.9 reads back as 12:00:00 and is older than a cutoff of 12:00:00.4; or the touch is written after the PONG goes out, so the query can run first. If the code is wrong (the touch can land after the reply, or a precision loss could expire a user who is active), fix the code; if only the test's timing is wrong, fix the test so its outcome does not depend on timing.

Definition of done

  1. The cause is stated in one line in the PR body.
  2. TestIdleCleanupKeepsActiveUser passes on every run: the author runs script/cibuild at least three times in a row on the branch, under the gate lock, and all pass.
  3. If the cause is in the code, a test that fails on the old code.
  4. One reviewed PR against next.

Model: opus-5-5

`TestIdleCleanupKeepsActiveUser` in `internal/ircserver/server_test.go` fails on some runs, which turns `script/cibuild` red on `next`. It failed on `ddfbdc1` with `cleanup removes [{1 active} {2 idle}], want only idle` and passed when the same build reran the suite with `-v`. The test registers `active` and `idle`, sleeps `idleTimeout` (500 ms), has `active` send `PING` and wait for the `PONG`, then asks `GetStaleOrphanSessions` for sessions last seen before now minus 500 ms, and expects only `idle`. Sometimes `active` is in the result too. Find out why before changing anything; two readings fit: the session's last-seen time is stored at whole-second precision, so a touch at 12:00:00.9 reads back as 12:00:00 and is older than a cutoff of 12:00:00.4; or the touch is written after the `PONG` goes out, so the query can run first. If the code is wrong (the touch can land after the reply, or a precision loss could expire a user who is active), fix the code; if only the test's timing is wrong, fix the test so its outcome does not depend on timing. ## Definition of done 1. The cause is stated in one line in the PR body. 2. `TestIdleCleanupKeepsActiveUser` passes on every run: the author runs `script/cibuild` at least three times in a row on the branch, under the gate lock, and all pass. 3. If the cause is in the code, a test that fails on the old code. 4. One reviewed PR against `next`. Model: opus-5-5
clawbot added the critical label 2026-10-21 06:34:32 +02:00
clawbot self-assigned this 2026-10-21 06:34:33 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/neoirc#181