Skip to content

Refresh stale archive ID cache when archive rows disappear#24246

Merged
sgiehl merged 2 commits into5.x-devfrom
fix/archive-cache-refresh-retry
Mar 19, 2026
Merged

Refresh stale archive ID cache when archive rows disappear#24246
sgiehl merged 2 commits into5.x-devfrom
fix/archive-cache-refresh-retry

Conversation

@sgiehl
Copy link
Member

@sgiehl sgiehl commented Mar 18, 2026

Summary

This PR fixes a stale-archive-cache issue in Archive::get() that can return empty data from valid reports when cached
archive IDs point to rows that no longer exist.

refs #24191

Problem

Archive caches archive IDs in-memory. If those rows are removed after the cache is populated, later reads in the same
request can still query with stale IDs and return no rows, leading to incorrect zeroed metrics.

Root Cause

Archive::get() trusted cached IDs unconditionally and had no recovery path when ArchiveSelector::getArchiveData()
returned empty for otherwise valid archive queries.

Fix

When archive data comes back empty, Archive::get() now:

  1. Clears in-memory archive ID/state cache.
  2. Fetches archive IDs/states again.
  3. Retries data fetch once.

Tests

Added integration regression tests in tests/PHPUnit/Integration/ArchiveTest.php:

  1. testStaleCachedArchiveIdsAreRefreshedWhenArchiveRowsAreMissing
  2. testStaleCachedArchiveIdsAreRefreshedAfterArchiveRowsArePurged

The second test reproduces the issue via normal flow (no reflection-based cache overwrite): cache is primed, archive
rows are removed, then the same Archive instance is queried again.

Expected Impact

Prevents false-empty archive reads and incorrect zero metrics when cached archive IDs become stale mid-request.

Checklist

  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

Review

@sgiehl sgiehl added this to the 5.9.0 milestone Mar 18, 2026
@sgiehl sgiehl requested a review from a team March 18, 2026 17:46
@sgiehl sgiehl marked this pull request as ready for review March 18, 2026 19:45
Copy link
Contributor

@chippison chippison left a comment

Choose a reason for hiding this comment

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

Code looks good.

Can't really do manual smoke/functional test for the issue here.
Run integration test and it works. Performed some archiving locally just to make sure everything is still good and everything works fine

@sgiehl sgiehl merged commit c01a763 into 5.x-dev Mar 19, 2026
50 of 51 checks passed
@sgiehl sgiehl deleted the fix/archive-cache-refresh-retry branch March 19, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants