Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryError in Persistent Cache #3183

Open
FlareBlitzV opened this issue Jul 18, 2023 · 1 comment
Open

OutOfMemoryError in Persistent Cache #3183

FlareBlitzV opened this issue Jul 18, 2023 · 1 comment

Comments

@FlareBlitzV
Copy link

I am trying to dump the data from a heap(in memory) cache to disk cache via iterator, this happens every 30 mins. While trying to do that getting Out of Memory. Not sure if this is due to cache corruption. Once the OutOfMemoryError occurs, the program restarts and while the cache initialized there is no error. But when the data is fetched from the cache OutOfMemoryError is thrown again.
Note: Both heap and disk cache are created with ehcache as two separate caches.

Ehcache Version: 3.8.1
OS: Windows 10
JDK: ZuluJDK_8_0_322

Cache Configuration:

persistentCacheManager = (PersistentCacheManager) CacheManagerBuilder.newCacheManagerBuilder()
.with(CacheManagerBuilder
.persistence(ehCacheData.getDiskStoragePath()))
.withCache(ehCacheData.getCacheName(), CacheConfigurationBuilder
.newCacheConfigurationBuilder(String.class, ArrayList.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.disk(450L, MemoryUnit.MB, true)))
.build(true);

Code Snippet:
Iterator<Cache.Entry<String, ArrayList>> iterator = heapCache.iterator();
while (iterator.hasNext()) {
Cache.Entry entry = (Cache.Entry)iterator.next();
diskCache.put(entry.getKey(),entry.getValue());
}
heapCache.clear();

Exception Stack trace:
Failed to allocate direct buffer for FileChannel read. Consider increasing the -XX:MaxDirectMemorySize property to allow enough space for the FileChannel transfer buffers|
Failed to allocate direct buffer for FileChannel read. Consider increasing the -XX:MaxDirectMemorySize property to allow enough space for the FileChannel transfer buffers|
OutOfMemoryError Occurred::java.lang.OutOfMemoryError: Java heap space|
Thread::Thread[AnalyticsCacheDumpThread,5,main]|

Found the below exception later while trying print the data from the disk cache:
Ehcache key xxxxxxxxxxxx.xxxxxx-x-x-xx-xxxxxxxxxx-xxxxxxxxx-xxxxxxxxxx-xxxx in possible inconsistent state - Similar messages will be suppressed for 30 seconds|
org.ehcache.spi.resilience.StoreAccessException: java.lang.RuntimeException: java.io.EOFException
at org.ehcache.core.exceptions.StorePassThroughException.handleException(StorePassThroughException.java:78)
at org.ehcache.impl.internal.store.offheap.AbstractOffHeapStore.internalGet(AbstractOffHeapStore.java:211)
at org.ehcache.impl.internal.store.offheap.AbstractOffHeapStore.containsKey(AbstractOffHeapStore.java:219)
at org.ehcache.core.EhcacheBase.containsKey(EhcacheBase.java:220)
XXXXXXXXXXXX...........................................

Caused by: java.lang.RuntimeException: java.io.EOFException
at org.ehcache.shadow.org.terracotta.offheapstore.disk.storage.FileBackedStorageEngine$FileChunk.readBuffer(FileBackedStorageEngine.java:601)
at org.ehcache.shadow.org.terracotta.offheapstore.disk.storage.FileBackedStorageEngine$FileChunk.readKeyBuffer(FileBackedStorageEngine.java:534)
at org.ehcache.shadow.org.terracotta.offheapstore.disk.storage.FileBackedStorageEngine.readKeyBuffer(FileBackedStorageEngine.java:265)
at org.ehcache.shadow.org.terracotta.offheapstore.storage.PortabilityBasedStorageEngine.equalsKey(PortabilityBasedStorageEngine.java:125)
at org.ehcache.shadow.org.terracotta.offheapstore.OffHeapHashMap.keyEquals(OffHeapHashMap.java:1005)
at org.ehcache.shadow.org.terracotta.offheapstore.OffHeapHashMap.computeIfPresentWithMetadata(OffHeapHashMap.java:2101)
at org.ehcache.shadow.org.terracotta.offheapstore.AbstractLockedOffHeapHashMap.computeIfPresentWithMetadata(AbstractLockedOffHeapHashMap.java:542)
at org.ehcache.shadow.org.terracotta.offheapstore.concurrent.AbstractConcurrentOffHeapMap.computeIfPresentWithMetadata(AbstractConcurrentOffHeapMap.java:781)
at org.ehcache.impl.internal.store.disk.EhcachePersistentConcurrentOffHeapClockCache.computeIfPresent(EhcachePersistentConcurrentOffHeapClockCache.java:175)
at org.ehcache.impl.internal.store.offheap.AbstractOffHeapStore.internalGet(AbstractOffHeapStore.java:184)
... 11 more
Caused by: java.io.EOFException
at org.ehcache.shadow.org.terracotta.offheapstore.disk.storage.FileBackedStorageEngine$FileChunk.readBuffer(FileBackedStorageEngine.java:594)
... 20 more

Kindly help me regarding this. Thank you.

@FlareBlitzV
Copy link
Author

Is there any chance that the cache was corrupted due to antivirus and is causing the following exception. Can anyone help me regarding this. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant