[ 
https://issues.apache.org/jira/browse/SOLR-17597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Gibney resolved SOLR-17597.
-----------------------------------
    Fix Version/s: 9.9
       Resolution: Fixed

> CaffeineCache ramBytes incorrect accounting on `put()`
> ------------------------------------------------------
>
>                 Key: SOLR-17597
>                 URL: https://issues.apache.org/jira/browse/SOLR-17597
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: main (10.0), 9.7
>            Reporter: Michael Gibney
>            Assignee: Michael Gibney
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 9.9
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> In most cases, usage of {{CaffeineCache.put()}} results in incorrect ramBytes 
> accounting. Replaced values (and keys) decrement {{ramBytes}} via 
> {{onRemoval()}}, so replaced values currently end up double-decrementing for 
> the replaced value in 
> [recordRamBytes()|https://github.com/apache/solr/blob/a4229e76771da0125b38204db01ea0934e09c4f4/solr/core/src/java/org/apache/solr/search/CaffeineCache.java#L297-L301].
> After a sufficient number of replacements via {{put()}}, {{ramBytes}} becomes 
> permanently negative, and is thus useless.
> The problem was masked in existing tests due to the behavior of the Caffeine 
> library in the case of reference equality between the old (replaced) value 
> and the new (replacement) value for the same ({{.equals()}}) key -- [the case 
> exercised in existing 
> tests|https://github.com/apache/solr/blob/a4229e76771da0125b38204db01ea0934e09c4f4/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java#L342-L345]
>  -- in which case {{onRemoval()}} is _not_ invoked (so there is no double 
> decrement).
> The problem is also masked in normal usage, since existing/default cache 
> implementations and invocation all currently use {{computeIfAbsent()}} 
> instead of {{put()}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to