test(server): de-flake the indexer-service retry test#325
Merged
Conversation
TestIndexerServiceRetriesAfterFetchError scripted two fetch failures, so recovery needed two wake-up tokens — but the service's new-block signal channel has capacity 1 and the subscription goroutine coalesces close headers into a single token. Under the -race scheduler that interleaving stranded the second retry on the 60s NewBlockWaitTimeout and tripped the test's 10s deadline (seen on #323's test-unit-cover). Restructure to be deterministic under any interleaving: - Phase 1 (busy-loop discriminator): one failure, NO signal sent — the correct loop must park; the pre-fix busy-loop recovered without a wake-up and now fails an explicit quiescence check instead of a fragile attempt-count bound. - Phase 2 (latch discriminator + recovery): a single signal is a single retry token; the latched pre-fix version stays parked and trips the deadline. Verified: 30 consecutive runs under -race; the latch and busy-loop variants of the service each still fail the test; service code untouched. Signed-off-by: puneetmahajan <59960662+puneet2019@users.noreply.github.com>
faebcf2 to
5fa9243
Compare
Signed-off-by: puneetmahajan <59960662+puneet2019@users.noreply.github.com>
phenix3443
approved these changes
Jul 9, 2026
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.
Fixes the
test-unit-coverflake that hit #323 (TestIndexerServiceRetriesAfterFetchError, 10s deadline).Root cause (my test, my bug)
The scenario scripted two fetch failures → recovery needed two wake-up tokens. But the service's
newBlockSignalhas capacity 1 and the subscription goroutine coalesces close headers into one token. Under the-racescheduler, the unlucky interleaving strands the second retry on the 60sNewBlockWaitTimeout→ the test's 10s deadline fires.Fix — deterministic two-phase design (test-only; service untouched)
Recovery now needs exactly one token → immune to coalescing under any interleaving.
Verification
-race— all pass.blockErr = nilremoved): fails with the stall signature ✓go test ./server/... -racegreen;server/indexer_service.gobyte-untouched.🤖 Generated with Claude Code