Skip to content

Remove unused ETag from invalidation tags to prevent non-volatile tag Set leak#180

Merged
koriym merged 2 commits into
bearsunday:1.xfrom
jingu:fix/remove-unused-etag-invalidation-tag
Jun 29, 2026
Merged

Remove unused ETag from invalidation tags to prevent non-volatile tag Set leak#180
koriym merged 2 commits into
bearsunday:1.xfrom
jingu:fix/remove-unused-etag-invalidation-tag

Conversation

@jingu

@jingu jingu commented Jun 29, 2026

Copy link
Copy Markdown
Member

Problem

ResourceStorage::getTags() registers the ETag as an invalidation tag for every resource-state (roPool) save:

$tags = [$etag, ($this->uriTag)($ro->uri)];

However, no code path ever invalidates by ETag. All invalidation goes through the URI tag (deleteEtag()invalidateTags([$uriTag])) or surrogate keys. HTTP 304 validation uses the separate etagPool (keyed by the ETag, not tagged by it), so it is unaffected.

Because the ETag is content-versioned (crc32 of the view), each content version creates a new, non-volatile tag Set (\0tags\0{etag}). Under a volatile-* eviction policy (required by RedisTagAwareAdapter), these Sets are never reclaimed and never read — a write-only memory leak that grows monotonically.

Production evidence

Measured on a production ElastiCache instance (full keyspace scan, read-only):

tag Set type count bytes
ETag (unused) 222,213 (61%) 75 MB
uriTag / surrogate (in use) 139,686 287 MB

The ETag Sets accounted for 61% of all tag Sets and were growing ~1.9k/hour, steadily consuming non-volatile memory that volatile-lru cannot evict.

Fix

Stop registering the ETag as an invalidation tag. The cache entry remains fully purgeable via its URI tag and surrogate keys, and HTTP 304 handling (the etagPool) is untouched.

Test

Adds testEtagIsNotRegisteredAsInvalidationTag: after saveValue(), invalidating by the ETag value must not purge the entry, while invalidating by the URI tag still does. Verified this test fails before the change (Failed asserting that null is not null) and passes after.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@koriym, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f12c6692-7291-468d-a02e-f14956cfbd6a

📥 Commits

Reviewing files that changed from the base of the PR and between cf08316 and e24c321.

📒 Files selected for processing (1)
  • .github/workflows/continuous-integration.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a4cd9e8) to head (e24c321).

Additional details and impacted files
@@             Coverage Diff             @@
##                 1.x      #180   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity       247       247           
===========================================
  Files             53        53           
  Lines            749       748    -1     
===========================================
- Hits             749       748    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jingu jingu force-pushed the fix/remove-unused-etag-invalidation-tag branch from 57622de to e24c321 Compare June 29, 2026 06:35
@jingu jingu marked this pull request as ready for review June 29, 2026 06:38
@koriym

koriym commented Jun 29, 2026

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@koriym koriym merged commit 1ffef18 into bearsunday:1.x Jun 29, 2026
20 checks passed
koriym added a commit that referenced this pull request Jun 29, 2026
Mirror of #180 (released in 1.16.2) for this branch: CacheTags::ofResource() — the
extracted form of ResourceStorage::getTags() — still registered the ETag as an
invalidation tag. The ETag is never invalidated by (all invalidation is by URI tag /
surrogate keys; HTTP 304 uses the separate ETag pool), and being content-versioned it
leaks one non-volatile tag Set per content version under a volatile-* eviction policy.

Drop the ETag from the resource-state tags; add testEtagIsNotRegisteredAsInvalidationTag
(invalidating by the ETag value must not purge the entry; the URI tag still does).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SJnuk1B1yXK6bxXuU9DGCo
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.

2 participants