Skip to content

Prevent WAN cache invalidation from purging concurrent refreshes - #9

Merged
jeffw16 merged 3 commits into
mainfrom
copilot/check-cache-invalidation-issues
Jul 29, 2026
Merged

Prevent WAN cache invalidation from purging concurrent refreshes#9
jeffw16 merged 3 commits into
mainfrom
copilot/check-cache-invalidation-issues

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

    • Rely exclusively on touchCheckKey() for cross-server invalidation.
    • Remove the redundant value-key deletion and its race window.
    • Continue clearing request-local memoized definitions.
  • Concurrency coverage

    • Verify stale fills racing invalidation are rejected after WAN holdoff.
    • Verify fresh fills completing during invalidation remain cached.
    • Exercise the production hotTTR, lockTSE, and cache-version options.
public function invalidate(): void {
	$this->cache->touchCheckKey( $this->getCheckKey() );
	$this->loaded = false;
	$this->memoizedDefinitions = [];
}
  • Documentation
    • Clarify that namespace saves invalidate through the WAN check key.

Copilot AI changed the title Fix WAN cache invalidation race Prevent WAN cache invalidation from purging concurrent refreshes Jul 29, 2026
Copilot AI requested a review from jeffw16 July 29, 2026 10:15
@jeffw16
jeffw16 requested a review from Copilot July 29, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 on touchCheckKey() 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 cache version.
  • 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).

@jeffw16
jeffw16 marked this pull request as ready for review July 29, 2026 18:09
@jeffw16
jeffw16 merged commit f48abe6 into main Jul 29, 2026
2 of 8 checks passed
@jeffw16
jeffw16 deleted the copilot/check-cache-invalidation-issues branch July 29, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants