Skip to content

imagecache: Fix TestConcurrentEnsureImageAndEvict flake - #1079

Closed
Max Thompson (thompsonmax) wants to merge 1 commit into
agent-substrate:mainfrom
thompsonmax:fix-ensureimage-evict-retry
Closed

imagecache: Fix TestConcurrentEnsureImageAndEvict flake#1079
Max Thompson (thompsonmax) wants to merge 1 commit into
agent-substrate:mainfrom
thompsonmax:fix-ensureimage-evict-retry

Conversation

@thompsonmax

Copy link
Copy Markdown
Collaborator

The reuse/retire protocol leaves one legitimate window: after ensureLayer refreshes a reused dir's mtime inside the layer singleflight, but before the image record rewrite re-references it, an eviction pass whose cutoff postdates the refresh may retire the dir. The pull's final re-verify caught this and failed the pull into an RPC retry, which TestConcurrentEnsureImageAndEvict (correctly, per its stated invariant) flagged as a flake under CI load.

Make the test's invariant true: when the re-verify finds a vanished layer dir, loop back and unpack the missing layers again, bounded to one extra attempt. One retry suffices because the winning pass listed its candidates before our record rewrite, so it cannot retire the re-unpacked dirs, and any later pass sees them referenced. Exhausting the attempts still fails with the original "vanished during pull" error.

TestPullReverifyFailsCleanlyOnYankedLayer asserted the old fail-clean behavior; it becomes TestPullReverifyRepullsYankedLayer, asserting the yanked layer is unpacked again and the pull succeeds.

Fixes #1076

The reuse/retire protocol leaves one legitimate window: after ensureLayer
refreshes a reused dir's mtime inside the layer singleflight, but before
the image record rewrite re-references it, an eviction pass whose cutoff
postdates the refresh may retire the dir. The pull's final re-verify
caught this and failed the pull into an RPC retry, which
TestConcurrentEnsureImageAndEvict (correctly, per its stated invariant)
flagged as a flake under CI load.

Make the test's invariant true: when the re-verify finds a vanished
layer dir, loop back and unpack the missing layers again, bounded to one
extra attempt. One retry suffices because the winning pass listed its
candidates before our record rewrite, so it cannot retire the
re-unpacked dirs, and any later pass sees them referenced. Exhausting
the attempts still fails with the original "vanished during pull" error.

TestPullReverifyFailsCleanlyOnYankedLayer asserted the old fail-clean
behavior; it becomes TestPullReverifyRepullsYankedLayer, asserting the
yanked layer is unpacked again and the pull succeeds.

Fixes agent-substrate#1076
@thompsonmax

Copy link
Copy Markdown
Collaborator Author

Superseded by #1509, will close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tests Enhancing / fixing test coverage. kind/bug Something isn't working / bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestConcurrentEnsureImageAndEvict flakes

2 participants