【发布时间】:2023-03-07 11:36:01
【问题描述】:
我们正在开发使用 ehcache 2.9.0 的应用程序。最近我们每周观察一次与 ehcache get/put 操作相关的死锁,一旦我们清除缓存,问题就会消失。
我们在缓存 get 操作期间观察 RandomAccessFile 上的锁,在 put 操作期间观察 ReentrantReadWriteLock。
请求 ehcache 专家提供有关可能出现的问题的见解?
PFB 来自线程转储的线程
"HTTP938" #25950 守护进程 prio=5 os_prio=0 tid=0x0000000002614000 nid=0x5a64 等待条件 [0x00007fcd36965000] java.lang.Thread.State:等待(停车) 在 sun.misc.Unsafe.park(本机方法) - 停车等待 (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync) 在 java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) 在 java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) 在 java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:967) 在 java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1283) 在 java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.lock(ReentrantReadWriteLock.java:727) 在 net.sf.ehcache.store.disk.Segment.flush(Segment.java:1010) 在 net.sf.ehcache.store.disk.DiskStore.flush(DiskStore.java:248) 在 net.sf.ehcache.store.CacheStore$1.evicted(CacheStore.java:99) 在 net.sf.ehcache.store.CacheStore$1.evicted(CacheStore.java:96) 在 net.sf.ehcache.store.cachingtier.OnHeapCachingTier$1.evicted(OnHeapCachingTier.java:86) 在 net.sf.ehcache.store.cachingtier.CountBasedBackEnd$1.removed(CountBasedBackEnd.java:103) 在 net.sf.ehcache.util.concurrent.ConcurrentHashMap.internalReplace(ConcurrentHashMap.java:1346) 在 net.sf.ehcache.util.concurrent.ConcurrentHashMap.removeAndNotify(ConcurrentHashMap.java:2647) 在 net.sf.ehcache.store.cachingtier.CountBasedBackEnd.remove(CountBasedBackEnd.java:115) 在 net.sf.ehcache.store.cachingtier.OnHeapCachingTier.remove(OnHeapCachingTier.java:206) 在 net.sf.ehcache.store.CacheStore.put(CacheStore.java:134) 在 net.sf.ehcache.Cache.putInternal(Cache.java:1600) 在 net.sf.ehcache.Cache.put(Cache.java:1526) 在 net.sf.ehcache.Cache.put(Cache.java:1491) 在 org.springframework.cache.ehcache.EhCacheCache.put(EhCacheCache.java:82) 在 org.springframework.cache.interceptor.AbstractCacheInvoker.doPut(AbstractCacheInvoker.java:82) 在 org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:651) 在 org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:358) 在 org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:299) 在 org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61) 在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 在 org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
"HTTP927" #25855 守护进程 prio=5 os_prio=0 tid=0x00007fce685c9000 nid=0x4fb6 等待监控入口 [0x00007fcd359e8000] java.lang.Thread.State: BLOCKED (在对象监视器上) 在 net.sf.ehcache.store.disk.DiskStorageFactory.read(DiskStorageFactory.java:362) - 等待锁定 (a java.io.RandomAccessFile) 在 net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:864) 在 net.sf.ehcache.store.disk.Segment.decode(Segment.java:171) 在 net.sf.ehcache.store.disk.Segment.remove(Segment.java:644) 在 net.sf.ehcache.store.disk.DiskStore.remove(DiskStore.java:625) 在 net.sf.ehcache.store.CacheStore.remove(CacheStore.java:236) 在 net.sf.ehcache.Cache.removeInternal(Cache.java:2401) 在 net.sf.ehcache.Cache.tryRemoveImmediately(Cache.java:2162) 在 net.sf.ehcache.Cache.get(Cache.java:1739) 在 org.springframework.cache.ehcache.EhCacheCache.get(EhCacheCache.java:65) 在 org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:68) 在 org.springframework.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:461) 在 org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:432) 在 org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:333) 在 org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:299) 在 org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61) 在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 在 org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
线程 HTTP762 在 0x00000005cbdfb538 上拥有监视器锁定 在 java.io.RandomAccessFile.readFully(RandomAccessFile.java:416) - 锁定 [0x00000005cbdfb538](一个 java.io.RandomAccessFile) 在 org.springframework.cache.ehcache.EhCacheCache.put(EhCacheCache.java:82) 谢谢, 尼维迪塔
【问题讨论】: