我基于apache ignite core jar 2.7.0构建缓存集群,服务器进程因OOM错误退出:
org.apache.ignite.logger.java.JavaLogger.error JVM will be halted immediately due to the failure: [failureCtx=FailureContext [type=CRITICAL_ERROR, err=class o.a.i.i.mem.IgniteOutOfMemoryException: Out of memory in data region [name=keywordRegion, initSize=256.0 MiB, maxSize=8.0 GiB, persistenceEnabled=false] Try the following:
^-- Increase maximum off-heap memory size (DataRegionConfiguration.maxSize)
^-- Enable Ignite persistence (DataRegionConfiguration.persistenceEnabled)
^-- Enable eviction or expiration policies]]
区域配置为:
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="name" value="keywordRegion"/>
<property name="maxSize" value="#{1024L * 1024 * 1024 * 8}"/>
<property name="pageEvictionMode" value="RANDOM_2_LRU"/>
<property name="persistenceEnabled" value="false"/>
</bean>
关于错误日志中给出的3条建议:
- 我想将缓存大小限制为8g;
- 我只想使用内存缓存;
- PageEvictionMode 设置为 RANDOM_2_LRU;
我测试了一些情况,当缓存值大小相同时,驱逐效果很好,当它们是随机大小时,会导致 OOM。 什么事?是不是配置错误了?谢谢。
编辑: 这是我的测试,最大区域大小设置为120M,OOM发生在第200次循环左右,当mega声明行移到for循环前面时,ignite工作良好。
IgniteCache<String, Object> keywordCache = ignite.getOrCreateCache("keyword");
for(int i=0;i<1000;i++){
int mega = new Random().nextInt(3) + 1;
keywordCache.put(UUID.randomUUID().toString(), new byte[mega * 1024 * 1024]);
System.out.println("current:"+i);
}
最佳答案
这些对象比 EvictionPolicy 中的emptyPagesPoolSize的默认属性大,因此,它可能会导致这种行为。您可以将此行添加到 DataRegionConfiguration:
<property name="emptyPagesPoolSize" value="5000"/>
我检查了您的再现器,它在应用此属性后可以正常工作。
关于点燃报告IgniteOutOfMemoryException : Out of memory in data region,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55937768/