ben-manes commented on a change in pull request #580: URL: https://github.com/apache/solr/pull/580#discussion_r797143819
########## File path: solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java ########## @@ -89,6 +86,21 @@ public TransientSolrCoreCacheDefault(CoreContainer coreContainer) { transientDescriptors = new LinkedHashMap<>(initialCapacity); } + private void onEvict(SolrCore core) { + if (core.getOpenCount() > 1) { Review comment: The way to handle this is to [pin entries](https://github.com/ben-manes/caffeine/wiki/Faq#pinning-entries). When an entry should be pinned you can update it through the cache (e.g. `cache.asMap.compute`) and have a `Weigher` to evaluate the entry's size as `0`. Then it won't take any capacity and be skipped over during size eviction. Similarly for expiration using an `Expiry` that gives an infinite lifetime. This approach is preferred because then the cache won't surprisingly violate the contracts, won't perform O(n) scans searching for candidates, and the decisions are more explicit. Caffeine skips over zero-weight entries, but in the future it could move them elsewhere. So far this pin/unpin approach seems to clearer than Ehcache's [EvictionAdvisor](https://github.com/ehcache/ehcache3/blob/master/ehcache-api/src/main/java/org/ehcache/config/EvictionAdvisor.java) (a soft no; will evict an entry [regardless](https://github.com/ehcache/ehcache3/blob/5cfa96b868423f0fbb19bf27ead647823b14a165/ehcache-impl/src/main/java/org/ehcache/impl/internal/store/heap/OnHeapStore.java#L1578-L1583) of the advice) and Coherence's [EvictionApprover](https://github.com/oracle/coherence/blob/d97c16ca8069143a8117356914da1bc341e8c19f/prj/coherence-core/src/main/java/com/tangosol/net/cache/ConfigurableCacheMap.java#L331-L364) is a hard no (which could lead to heap exhaustion), but please let me know if you ru n into issues that advocate for reevaluating our approach. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org