Skip to content

test(consensus): fix flaky TestByzantinePrevoteEquivocation (backport #5814) - #5841

Merged
mergify[bot] merged 1 commit into
v0.38.xfrom
mergify/bp/v0.38.x/pr-5814
May 7, 2026
Merged

mergify[bot] merged 1 commit into
v0.38.xfrom
mergify/bp/v0.38.x/pr-5814

Conversation

@mergify

@mergify mergify Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix the failing CI at https://github.com/cometbft/cometbft/actions/runs/25421557069/job/74564693795?pr=5837

TestByzantinePrevoteEquivocation was sporadically timing out on CI under the -race detector. The root cause was goroutine leaks: subscriptions were created with context.Background(), so the subscriber goroutines had no clean exit path when a block with evidence never arrived — they blocked forever on sub.Out(), leaked across tests, and exhausted resources on the runner.

Changes

  • Replace for range sub.Out() with a select that also handles sub.Canceled(), so goroutines exit cleanly when the eventbus stops during test cleanup
  • Add subErrCh to surface unexpected subscription cancellation errors instead of silently swallowing them

Test plan

## Summary
Fix the failing CI at
https://github.com/cometbft/cometbft/actions/runs/25421557069/job/74564693795?pr=5837

`TestByzantinePrevoteEquivocation` was sporadically timing out on CI
under the `-race` detector. The root cause was goroutine leaks:
subscriptions were created with `context.Background()`, so the
subscriber goroutines had no clean exit path when a block with evidence
never arrived — they blocked forever on `sub.Out()`, leaked across
tests, and exhausted resources on the runner.

## Changes

- Replace `for range sub.Out()` with a `select` that also handles
`sub.Canceled()`, so goroutines exit cleanly when the eventbus stops
during test cleanup
- Add `subErrCh` to surface unexpected subscription cancellation errors
instead of silently swallowing them

## Test plan

- [x] `go test ./consensus/... -run TestByzantinePrevoteEquivocation -v
-count=1` passes locally
- [x] CI passing

(cherry picked from commit f56fbf1)
@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@mattac21
mattac21 enabled auto-merge May 7, 2026 14:04
@mergify
mergify Bot merged commit a82d977 into v0.38.x May 7, 2026
18 checks passed
@mergify
mergify Bot deleted the mergify/bp/v0.38.x/pr-5814 branch May 7, 2026 14:09
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.

2 participants