Skip to content

fix(flytestdlib): fix race condition in TestCacheFour Enqueue nothing - #7844

Merged
Sovietaced merged 1 commit into
flyteorg:mainfrom
VedantMadane:fix-flaky-test-cache-four
Aug 14, 2026
Merged

fix(flytestdlib): fix race condition in TestCacheFour Enqueue nothing#7844
Sovietaced merged 1 commit into
flyteorg:mainfrom
VedantMadane:fix-flaky-test-cache-four

Conversation

@VedantMadane

Copy link
Copy Markdown
Contributor

Fixes #7843

Summary

Fixes a race condition in TestCacheFour/Enqueue_nothing (and related subtests in flytestdlib/cache/in_memory_auto_refresh_test.go) where fakeClock.Step() executed before enqueueLoop finished setting or re-arming its timer.

Changes

  1. Isolated Fake Clocks: Instantiated isolated testingclock.NewFakeClock() instances per subtest in TestCacheFour to prevent timer step cross-talk.
  2. Waiter Assertions: Added assert.Eventually(t, fakeClock.HasWaiters, ...) checks before fakeClock.Step(...) calls to ensure the background enqueueLoop goroutine has armed/re-armed its timer.
  3. Verification: Ran go test -v ./flytestdlib/cache -run TestCacheFour and confirmed all 6 subtests pass consistently.

@pingsutw pingsutw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@VedantMadane Thanks for your contribution, could you take a look at the unit test failure?

@Sovietaced

Copy link
Copy Markdown
Member

@VedantMadane can you rebase to pick up my build fix

Signed-off-by: Vedant Madane <vedantnm@gmail.com>
@VedantMadane
VedantMadane force-pushed the fix-flaky-test-cache-four branch from f94db53 to ec67c82 Compare August 14, 2026 09:31
@VedantMadane

Copy link
Copy Markdown
Contributor Author

@Sovietaced Rebased onto latest main! Thanks.

@Sovietaced
Sovietaced enabled auto-merge (squash) August 14, 2026 15:43
@Sovietaced
Sovietaced merged commit 489dc4d into flyteorg:main Aug 14, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: TestCacheFour/"Enqueue nothing" is flaky on main — clock.Step races the timer re-arm

3 participants