Skip to content

fix(internal.clock): Fix flaky TestUnalignedTicker race condition#18515

Open
skartikey wants to merge 1 commit intoinfluxdata:masterfrom
skartikey:fix/unaligned-ticker-flaky-test
Open

fix(internal.clock): Fix flaky TestUnalignedTicker race condition#18515
skartikey wants to merge 1 commit intoinfluxdata:masterfrom
skartikey:fix/unaligned-ticker-flaky-test

Conversation

@skartikey
Copy link
Contributor

Summary

The select/default loop with clk.Add(1s) raced with the ticker goroutine's timer.Reset() call, causing the mock clock to advance between clk.Until() and timer.Reset(), shifting the timer deadline by 1 second.

Replace the select/default loop with blocking channel reads. Since Timer(0) fires immediately inside the constructor, no clock advance is needed for the first tick. Blocking on each subsequent read ensures timer.Reset() completes before the next clk.Add().

Checklist

Related issues

resolves #

The select/default loop with clk.Add(1s) raced with the ticker
goroutine's timer.Reset() call, causing the mock clock to advance
between clk.Until() and timer.Reset(), shifting the timer deadline
by 1 second.

Replace the select/default loop with blocking channel reads. Since
Timer(0) fires immediately inside the constructor, no clock advance
is needed for the first tick. Blocking on each subsequent read ensures
timer.Reset() completes before the next clk.Add().
@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Mar 11, 2026
@skartikey skartikey self-assigned this Mar 11, 2026
@telegraf-tiger
Copy link
Contributor

@skartikey skartikey assigned srebhan and unassigned skartikey Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix pr to fix corresponding bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants