0

我们在生产环境中不断出现死锁错误。日志文件中的错误消息如下

2013-04-24 01:44:28,893 ERROR [gk.lvl1Executor-1] - Transaction (Process ID 68) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
2013-04-24 01:44:28,906 ERROR [gk.lvl1Executor-1] - Error in action
org.hibernate.exception.LockAcquisitionException: could not execute query

此错误由代码引起:

Transaction transaction = (Transaction) session.createQuery("from Transaction tr where " +
"tr.transactionId = :transId and " +
"tr.aseXml.flowDirection = :flowDirection and " + 
"tr.aseXml.header.to = :from and " +
"tr.aseXml.header.from = :to and " +
"tr.aseXml.header.market = :market and "+
"tr.aseXml.header.transactionGroup = :trGroup")
.setString("transId", aTransactionId)
.setString("flowDirection", aFlowDirection)
.setString("from", aHeader.getFrom())
.setString("to", aHeader.getTo())
.setString("market", aHeader.getMarket())
.setString("trGroup", aHeader.getTransactionGroup())
.setFetchSize(1)
.setMaxResults(1)
.setCacheable(true)
.uniqueResult();

这只是一个选择查询。不知道为什么会导致死锁。我应该提到的另一件事是隔离级别设置为REPEATABLE_READ.

4

0 回答 0