Skip to content

test: fix the heartbeat data race and the subscriber-baseline wait in the finalization wiring tests - #428

Merged
PHPCraftdream merged 2 commits into
mainfrom
fix/ci-flakes-20261115
Nov 15, 2026
Merged

PHPCraftdream merged 2 commits into
mainfrom
fix/ci-flakes-20261115

Conversation

@PHPCraftdream

Copy link
Copy Markdown
Owner

Two flaky tests, fixed at their mechanism (#157)

Both showed up as red jobs in unrelated fork CI runs; neither is a product defect.

  1. heartbeat data race under -race (race-ubuntu): TestRevisitAfterEvictNotSilentlyZero called getModel without registry.Lock(). Every production caller holds the lock, and the background flush worker (started by an earlier test through ensureWorker, alive for the rest of the package run) clones the same model map under it. The test now takes the lock.
  2. finalization_wiring_test, windows shard: three tests read GetSubscriberCount()+1 after starting startAPIEventFeeder / subscribeAndBroadcast, which subscribe from their own goroutines; a fast subscription was already counted and the wait targeted one subscriber that never came ("gated ws message feed never reached 2 subscribers (got 1)" after 5 s). The baseline is now read before starting. Reproduced deterministically by delaying the baseline read by 300 ms: the old order fails with exactly that message, the new order passes.

Full fork CI run 43751366961 on 793eb9008 is green (22 jobs, including race-ubuntu and windows shard C).

🤖 Generated with Claude Code

PHPCraftdream and others added 2 commits November 15, 2026 20:14
…before starting the feed

startAPIEventFeeder and subscribeAndBroadcast subscribe from their own
goroutines; the tests read GetSubscriberCount()+1 after starting them, so a
fast subscription was already counted and the wait targeted one subscriber
that never came ("gated ws message feed never reached 2 subscribers (got 1)"
after 5 s, seen on the windows shard C). The baseline is now read first.
Reproduced by delaying the baseline read by 300 ms: the old order fails with
exactly that message, the new order passes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…under registry.Lock

getModel mutates the row's model map; every production caller holds the
registry lock, the test did not. The flush worker that an earlier test starts
through ensureWorker (alive for the rest of the package run) clones the same
map under the lock, so the -race job of the fork CI reported a data race
(heartbeat.go:563/565 against budget.go:26/27 via writer.go:84).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@PHPCraftdream
PHPCraftdream merged commit d0a3413 into main Nov 15, 2026
1 check passed
@PHPCraftdream
PHPCraftdream deleted the fix/ci-flakes-20261115 branch November 15, 2026 20:23
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