[英]Infinispan 9, Replicated Cache is Expiring Entries but never allows them to be removed from JVM heap
Was doing some internal testing about a clustering solution on top of infinispan/jgroups and noticed that the expired entries were never becoming eligible for GC, due to a reference on the expiration-reaper, while having more than 1 nodes in the cluster with expiration enabled / eviction disabled.正在对 infinispan/jgroups 之上的集群解决方案进行一些内部测试,并注意到由于对过期收割机的引用,过期的条目永远不会符合 GC 的条件,同时集群中有超过 1 个启用过期的节点/ 驱逐禁用。 Due to some system difficulties the below versions are being used:
由于一些系统问题,正在使用以下版本:
In my example I am using a simple Java main scenario, placing a specific number of data, expecting them to expire after a specific time period.在我的示例中,我使用了一个简单的 Java 主要场景,放置特定数量的数据,期望它们在特定时间段后过期。 The expiration is indeed happening, as it can be confirmed both while accessing the expired entry and by the respective event listener(if its configured), by it looks that it is never getting removed from the available memory, even after an explicit GC or while getting close to an OOM error.
过期确实发生了,因为它可以在访问过期条目和相应的事件侦听器(如果已配置)时确认,它看起来永远不会从可用的 memory 中删除,即使在显式 GC 之后或同时接近 OOM 错误。
So the question is:所以问题是:
Is this really expected as default behavior, or I am missing a critical configuration as per the cluster replication / expiration / serialization?这真的是预期的默认行为,还是我错过了集群复制/到期/序列化的关键配置?
Example:例子:
Cache Manager:缓存管理器:
return new DefaultCacheManager("infinispan.xml");
infinispan.xml: infinispan.xml:
<jgroups>
<stack-file name="udp" path="jgroups.xml" />
</jgroups>
<cache-container default-cache="default">
<transport stack="udp" node-name="${nodeName}" />
<replicated-cache name="myLeakyCache" mode="SYNC">
<expiration interval="30000" lifespan="3000" max-idle="-1"/>
</replicated-cache>
</cache-container>
Default UDP jgroups xml as in the packaged example:默认 UDP jgroups xml 如打包示例所示:
..... ......
<UDP
mcast_addr="${jgroups.udp.mcast_addr:x.x.x.x}"
mcast_port="${jgroups.udp.mcast_port:46655}"
bind_addr="${jgroups.bind.addr:y.y.y.y}"
tos="8"
ucast_recv_buf_size="200k"
ucast_send_buf_size="200k"
mcast_recv_buf_size="200k"
mcast_send_buf_size="200k"
max_bundle_size="64000"
ip_ttl="${jgroups.udp.ip_ttl:2}"
enable_diagnostics="false"
bundler_type="old"
thread_naming_pattern="pl"
thread_pool.enabled="true"
thread_pool.max_threads="30"
/>
The dummy cache entry:虚拟缓存条目:
public class CacheMemoryLeak implements Serializable {
private static final long serialVersionUID = 1L;
Date date = new Date();
}
An example usage from the "service": “服务”的示例用法:
Cache<String, Object> cache = cacheManager.getCache("myLeakyCache");
cache.put(key, new CacheMemoryLeak());
Some info / tryouts:一些信息/试用:
As it seems noone else had the same issue or using primitive objects as cache entries, thus haven't noticed the issue.因为似乎没有其他人有同样的问题或使用原始对象作为缓存条目,因此没有注意到这个问题。 Upon replicating and fortunately traced the root cause, the below points are coming up:
在复制并幸运地追查到根本原因后,出现了以下几点:
hashCode
/ equals
for custom objects that are going to end been transmitted through a replicated/synchronized cache.hashCode
/ equals
。hashcode
/ equals
would not be calculated - efficiently-hashcode
码/ equals
- 有效 -
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.