Michael Gibney created SOLR-17597:
-------------------------------------
Summary: 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: 9.7, main (10.0)
Reporter: Michael Gibney
Assignee: Michael Gibney
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: [email protected]
For additional commands, e-mail: [email protected]