[英]EhCache Deadlock issue while using RMI Cache Replicator
我在使用RMI緩存復制器策略時遇到應用程序中的緩存死鎖問題。 以下是異常日志:
net.sf.ehcache.transaction.DeadLockException: deadlock detected in cache [abcCache] on key [1] between current transaction [139003] and foreign transaction [138998]
at net.sf.ehcache.transaction.local.LocalTransactionStore.put(LocalTransactionStore.java:200)
at net.sf.ehcache.transaction.local.JtaLocalTransactionStore.put(JtaLocalTransactionStore.java:268)
at net.sf.ehcache.Cache.putInternal(Cache.java:1434)
at net.sf.ehcache.Cache.put(Cache.java:1367)
at net.sf.ehcache.Cache.put(Cache.java:1339)
以下是我的帶有RMI同步的ehcache配置:
<transactionManagerLookup
class="net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup"
properties="jndiName=java:comp/UserTransaction" propertySeparator=";"/>
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic, multicastGroupAddress=x.x.x.x, multicastGroupPort=xxxx, timeToLive=32"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="port=40001, socketTimeoutMillis=2000"/>
<cache
name="abcCache"
maxElementsInMemory="100"
eternal="false"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="0"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU"
transactionalMode="xa">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicatePuts=true, replicateUpdates=true, replicateRemovals=true, replicateUpdatesViaCopy=false, replicateAsynchronously=true, asynchronousReplicationIntervalMillis=500"/>
</cache>
我正在使用ehcache-core ver 2.4.3
。 感謝任何幫助。
這可能不是您要找的答案,但是RMI復制和事務性緩存不一起支持。 現在,DeadLock的原因不一定是RMI復制。 您可以在這里閱讀不同的事務處理模式: http ://ehcache.org/documentation/apis/transactions但是,基本上,除了在xa_strict環境中,您可能會得到這些。 因此,如果這是您不願意支付的價格,則需要確保所有事務在超時之前都能設法訪問條目(即長時間超時將解決您的問題)。 如果xa&本地事務緩存不能在該超時時間內“鎖定”該條目,則將引發異常,因為該條目當前已被另一個事務/線程鎖定。 希望這是有道理的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.