繁体   English   中英

使用RMI缓存复制器时出现EhCache死锁问题

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM