【问题标题】:Dead Lock with JBoss Cache 1.4.1JBoss Cache 1.4.1 的死锁
【发布时间】:2012-01-19 23:38:00
【问题描述】:

我正在使用:JBoss AS 4.2.3、JBoss Cache 1.4.1 SP12、Hibernate 3.2.6; JPA 1.0.1 与

<attribute name="NodeLockingScheme">PESSIMISTIC</attribute>
<attribute name="IsolationLevel">READ_COMMITTED</attribute>

<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.use_structured_entries" value="true"/>
<property name="hibernate.cache.usage" value="transactional"/>
<property name="hibernate.cache.provider_class"
          value="org.hibernate.cache.TreeCacheProvider"/>
<property name="hibernate.treecache.local_puts_only" value="true"/>
<property name="hibernate.treecache.querycache.local_writes_only" value="true"/>

设置;

我有这样的实体:

@Entity  
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL, region = "AccountCache")  
public class Account {  
    ...some fields and methods...  
}

@Entity
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class User {
    ....
    @ManyToOne
    private Account account;
    ....
}

所以,我有计时器服务,它获取有关 Account 的信息并做一些事情(不更改 Account,只是获取并更改另一个实体)。当用户登录并在页面中工作时(切换页面,在其中做一些事情(不更改AccountUser 实体)),此时计时器服务开始工作,用户页面被阻止,并在 15 秒后抛出错误:

....many lines of stack and such errors...
Error performing load command
org.hibernate.cache.CacheException: org.jboss.cache.lock.TimeoutException: 
failure acquiring lock: fqn=/default/AccountCache, 
caller=Thread[http-192.0.2.58-80-6,5,jboss], lock=write 
owner=GlobalTransaction:<null>:88 (org.jboss.cache.lock.LockStrategyReadCommitted@63b596)
....many lines of stack and such errors...

看来GlobalTransaction:&lt;null&gt;:88是用户tx,callertimer service

通常用户线程工作正常,不到 15 秒。如果在Account 中禁用@Cache 一切正常(似乎)。

如果启用Optimistic锁方案,在同一并发下(有时)会抛出这样的错误:

Caused by: org.jboss.cache.optimistic.DataVersioningException:
Tx attempted to create /default/AccountCache/com.****.entity.account.Account#1 anew.
It has already been created since this tx started by another (possibly remote) tx.

还有问题))) 有什么问题?是TreeCache 问题,还是我的应用程序问题? 我做错了什么?由容器管理的所有事务...

【问题讨论】:

标签: hibernate jakarta-ee concurrency deadlock second-level-cache


【解决方案1】:

首先尝试通过删除物理文件或以编程方式清除缓存。如果没有,请尝试使用&lt;attribute name="NodeLockingScheme"&gt;MVCC&lt;/attribute&gt;,乐观和悲观锁定方案无论如何都已弃用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-21
    • 2014-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    相关资源
    最近更新 更多