Kailash Kothari - 2012-01-03

I just turned on overflowToDisk and ehcache is slowing down my application due to blocked threads. The relevant part of the thread dump is pasted below. There seems to be some blockage due to disk cache eviction (although that might not be the only cause). Is there a way to turn off disk cache eviction entirely?

"http-1876-40" daemon prio=10 tid=0x0000002b0b3fe000 nid=0x1f26 waiting for monitor entry

java.lang.Thread.State: BLOCKED (on object monitor)
at org.hibernate.cache.ReadOnlyCache.get(ReadOnlyCache.java:58)
- waiting to lock <0x0000002aa1f82800> (a org.hibernate.cache.ReadOnlyCache)
at
org.hibernate.cache.impl.bridge.EntityAccessStrategyAdapter.get(EntityAccessStrategyAdapter.java:55)

at
org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.j
ava:524)

"http-1876-38" daemon prio=10 tid=0x0000002b0b3fc800 nid=0x1f24 waiting for monitor entry

java.lang.Thread.State: BLOCKED (on object monitor)
at org.hibernate.cache.ReadOnlyCache.put(ReadOnlyCache.java:79)
- waiting to lock <0x0000002aa1f82800> (a org.hibernate.cache.ReadOnlyCache)
at
org.hibernate.cache.impl.bridge.EntityAccessStrategyAdapter.putFromLoad(EntityAccessStrategyAdapter.
java:68)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:179)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)

"http-1876-5" daemon prio=10 tid=0x0000002b05a9d000 nid=0x7e5d waiting for monitor entry

java.lang.Thread.State: BLOCKED (on object monitor)
at net.sf.ehcache.store.DiskStore.get(DiskStore.java:238)
- waiting to lock <0x0000002aa2276b80> (a net.sf.ehcache.store.DiskStore)
at net.sf.ehcache.Cache.searchInDiskStore(Cache.java:1202)
at net.sf.ehcache.Cache.get(Cache.java:803)
- locked <0x0000002aa2276ad0> (a net.sf.ehcache.Cache)
at net.sf.ehcache.hibernate.EhCache.get(EhCache.java:82)
at org.hibernate.cache.ReadOnlyCache.get(ReadOnlyCache.java:58)
- locked <0x0000002aa1f82800> (a org.hibernate.cache.ReadOnlyCache)
at
org.hibernate.cache.impl.bridge.EntityAccessStrategyAdapter.get(EntityAccessStrategyAdapter.java:55)

at
org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.j
ava:524)

"Store com.model.EA Spool Thread" daemon prio=10 tid=0x0000002b06c5e800
nid=0x7e4e runnable
java.lang.Thread.State: RUNNABLE
at net.sf.ehcache.store.DiskStore.sampleElements(DiskStore.java:1149)
at net.sf.ehcache.store.DiskStore.findRelativelyUnused(DiskStore.java:1134)
at net.sf.ehcache.store.DiskStore.evictLfuDiskElement(DiskStore.java:1123)
- locked <0x0000002aa42f7570> (a java.util.Collections$SynchronizedMap)
at net.sf.ehcache.store.DiskStore.writeOrReplaceEntry(DiskStore.java:677)
at net.sf.ehcache.store.DiskStore.flushSpool(DiskStore.java:651)
- locked <0x0000002aa2276b80> (a net.sf.ehcache.store.DiskStore)
at net.sf.ehcache.store.DiskStore.throwableSafeFlushSpoolIfRequired(DiskStore.java:628)
at net.sf.ehcache.store.DiskStore.spoolAndExpiryThreadMain(DiskStore.java:596)
at net.sf.ehcache.store.DiskStore.access$800(DiskStore.java:64)
at net.sf.ehcache.store.DiskStore$SpoolAndExpiryThread.run(DiskStore.java:1033)