Skip to content

fix: resolve race condition in TestContainerStore_die#4591

Merged
amir20 merged 1 commit intomasterfrom
fix/flaky-container-store-die-test
Apr 5, 2026
Merged

fix: resolve race condition in TestContainerStore_die#4591
amir20 merged 1 commit intomasterfrom
fix/flaky-container-store-die-test

Conversation

@amir20
Copy link
Copy Markdown
Owner

@amir20 amir20 commented Apr 5, 2026

Summary

  • TestContainerStore_die was flaky due to a race between init() forwarding the "die" event and the test calling SubscribeEvents
  • Added a ready channel to gate mock event delivery until the subscriber is registered

Test plan

  • go test -race -count 5 passes consistently
  • CI green

🤖 Generated with Claude Code

The test could hang forever because init() might process and forward the
"die" event before SubscribeEvents registered the test's channel. Gate
the mock's event delivery with a ready channel closed after subscribing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude bot commented Apr 5, 2026

Correct fix. The ready channel properly gates event delivery until SubscribeEvents is called, eliminating the race.

  • Pattern is idiomatic Go for test synchronization
  • close(ready) is the right choice over ready <- struct{}{} since it unblocks exactly once with no goroutine leak risk
  • No issues found

@amir20 amir20 enabled auto-merge (squash) April 5, 2026 22:46
@amir20 amir20 merged commit 5abda9f into master Apr 5, 2026
12 checks passed
@amir20 amir20 deleted the fix/flaky-container-store-die-test branch April 5, 2026 22:47
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