Skip to content

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

Merged
mstrandboge merged 1 commit intoinfluxdata:masterfrom
skartikey:fix/unaligned-ticker-flaky-test
Mar 12, 2026
Merged

test(internal.clock): Fix flaky TestUnalignedTicker race condition#18515
mstrandboge merged 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
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @skartikey!

@srebhan srebhan added ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. area/agent labels Mar 12, 2026
@srebhan srebhan assigned mstrandboge and unassigned srebhan Mar 12, 2026
@srebhan srebhan changed the title fix(internal.clock): Fix flaky TestUnalignedTicker race condition test(internal.clock): Fix flaky TestUnalignedTicker race condition Mar 12, 2026
@telegraf-tiger telegraf-tiger bot added the test label Mar 12, 2026
@srebhan srebhan added test and removed fix pr to fix corresponding bug test labels Mar 12, 2026
@mstrandboge mstrandboge merged commit c94d897 into influxdata:master Mar 12, 2026
28 of 29 checks passed
@github-actions github-actions bot added this to the v1.38.1 milestone Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants