Fix flaky Playground local cache tests - #39918
Open
bvolpato wants to merge 2 commits into
Open
Conversation
bvolpato
force-pushed
the
bvolpato/deflake-playground-local-cache
branch
from
August 29, 2026 22:51
cb0d5fd to
c792663
Compare
bvolpato
marked this pull request as ready for review
August 29, 2026 23:05
Contributor
|
Assigning reviewers: R: @damccorm added as fallback since no labels match configuration Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
bvolpato
marked this pull request as draft
August 30, 2026 05:29
bvolpato
force-pushed
the
bvolpato/deflake-playground-local-cache
branch
from
August 30, 2026 05:38
c792663 to
10038b9
Compare
bvolpato
marked this pull request as ready for review
August 30, 2026 05:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two local-cache tests depended on runner timing or unsynchronized state:
TestLocalCache_GetValueandTestLocalCache_SetValueexpired fixtures one millisecond after setup. Slow runners could cross that deadline before assertions ran. Their non-expired fixtures now use a one-minute deadline.TestLocalCache_startGCslept for one millisecond, then read the cache map while the GC goroutine could delete from it. It now polls for cleanup within a bounded deadline while holding the cache mutex. Each subtest owns its context and expiration state, and the nil-cache case still verifies that GC stops.Production cache behavior is unchanged.
Reproduction
The scheduled Playground precommit failed in
TestLocalCache_SetValue/Set_valuebecauseGetValuereported the newly stored value as missing:https://github.com/apache/beam/actions/runs/33273173203
The GC race reproduced immediately with:
Race detector reported an unlocked test read at
local_cache_test.go:575concurrent with deletion inCache.clearItems.Testing
cd playground/backend && go test ./internal/cache/localcd playground/backend && go test ./internal/cache/local -run '^TestLocalCache_(GetValue|SetValue)$' -count=10000cd playground/backend && go test -race ./internal/cache/local -run '^TestLocalCache_(GetValue|SetValue)$' -count=100cd playground/backend && go test -race ./internal/cache/local -run '^TestLocalCache_startGC$' -count=1000cd playground/backend && go test -race ./internal/cache/local -count=1./gradlew :playground:backend:testalso ran the changed cache package successfully, then stopped on unrelated local emulator and Scio setup failures.CHANGES.mdis unchanged because this is a test-only stabilization.