Skip to content

Conversation

@snazy
Copy link
Member

@snazy snazy commented Nov 3, 2025

There is sadly no fix possible with Caffeine since 3.2.3. See this reply.

The workaround I came up with is to change the logic a bit:

  • If the cache-weight is less than the capacity: just put the entry to the cache, no "special handling".
  • Otherwise do the following while holding an exclusive lock:
    • Explicitly trigger cache cleanup
    • If the cache-weight is less than the admitted capacity (overshooting), put the entry into the cache.
    • Else, reject and update meters accordingly.

We have to allow the "overshooting" to happen to enable (and trigger) the cache cleanup. Otherwise, cleanup would never happen ...

@snazy snazy force-pushed the cache-overshoot-fix branch from 15b2fbc to 2cb620f Compare November 3, 2025 18:57
@dimas-b
Copy link
Member

dimas-b commented Nov 3, 2025

How do we want to proceed wrt caffeine upgrade #11553? This PR first? or last?

There is sadly no fix possible with Caffeine since 3.2.3. See [this reply](ben-manes/caffeine#1897 (comment)).

The workaround I came up with is to change the logic a bit:

* If the cache-weight is less than the capacity: just put the entry to the cache, no "special handling".
* Otherwise do the following while holding an exclusive lock:
  * Explicitly trigger cache cleanup
  * If the cache-weight is less than the admitted capacity (overshooting), put the entry into the cache.
  * Else, reject and update meters accordingly.

We have to allow the "overshooting" to happen to enable (and trigger) the cache cleanup. Otherwise, cleanup would never happen ...
@snazy snazy force-pushed the cache-overshoot-fix branch from 2cb620f to 78d5d4c Compare November 3, 2025 19:55
@snazy
Copy link
Member Author

snazy commented Nov 3, 2025

🤦 i thought that PR was already merged. Let me close this one and cherry-pick the commit onto #11553

@snazy snazy closed this Nov 3, 2025
@snazy snazy deleted the cache-overshoot-fix branch November 3, 2025 20:13
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