Prevent WAN cache invalidation from purging concurrent refreshes - #9
Merged
Conversation
Copilot
AI
changed the title
Fix WAN cache invalidation race
Prevent WAN cache invalidation from purging concurrent refreshes
Jul 29, 2026
Copilot created this pull request from a session on behalf of
jeffw16
July 29, 2026 10:15
View session
There was a problem hiding this comment.
Pull request overview
This PR removes a race window in NamespaceRepository::invalidate() where a concurrent WANObjectCache refresh could complete between “touch check key” and “delete value key” and then be immediately discarded. The change makes invalidation rely solely on the WAN check key (while still clearing request-local memoization) and adds integration tests to exercise the concurrency behavior.
Changes:
- Remove value-key deletion from
NamespaceRepository::invalidate()and rely ontouchCheckKey()for cross-server invalidation. - Add integration tests covering stale cache fills racing invalidation (rejected after holdoff) and fresh fills completing during invalidation (remain cached), using
hotTTR,lockTSE, and cacheversion. - Update README to clarify that namespace saves invalidate via the WAN check key.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/NamespaceRepository.php |
Removes value-key deletion during invalidation to eliminate the refresh race window and rely on check-key invalidation. |
tests/phpunit/integration/NamespaceRepositoryTest.php |
Adds concurrency-focused integration tests that simulate racing fills/invalidation using WANObjectCache behavior. |
README.md |
Updates documentation to match the new invalidation behavior (check key only). |
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.
Namespace definition invalidation touched the WAN check key and then deleted the cached value. A refresh completing between those operations could be immediately discarded.
Changes
Invalidation
touchCheckKey()for cross-server invalidation.Concurrency coverage
hotTTR,lockTSE, and cache-version options.