弹出锁定超时与表中的并发更新

时间:2016-03-24 15:09:11

标签: hibernate jpa concurrency spring-boot h2

我使用spring boot,hibernate,JPA存储库和事件驱动应用程序的反应器来处理WebService。 我已经完成了一系列并行运行的长工作,并且我试图解决由此异常流引起的错误:

Could not execute statement; SQL [n/a]; nested exception is org.hibernate.PessimisticLockException: could not execute statement
org.springframework.dao.PessimisticLockingFailureException: could not execute statement; SQL [n/a];nested exception is org.hibernate.PessimisticLockException: could not execute statement
...
Caused by: org.hibernate.PessimisticLockException: could not execute statement
...
Caused by: org.h2.jdbc.JdbcSQLException: Timeout trying to lock table ; SQL statement: update 
...
Caused by: org.h2.jdbc.JdbcSQLException: Concurrent update in table "INTERACTIVE_EXPERIMENT": another transaction has updated or deleted the same row [90131-191]
...
Caused by: reactor.core.support.Exceptions$ValueCause: Exception while signaling value: reactor.bus.Event.class : Event{id=null, headers=null, replyTo=null, key=channel2, data=InteractiveExperiment(id=60, instanceName=myJson, simulationsManager=it.polimi.diceH2020.launcher.model.SimulationsWIManager@2a074bbd, simType=WI, thinkTime=10000, numUsers=1, numVMs=1, responseTime=0.0, gamma=null, provider=, numSolutions=0, iter=3, experimentalDuration=0, state=error, done=false)}

我得到"表中的并发更新" INTERACTIVE_EXPERIMENT":另一个事务更新或删除了相同的行",我已经并发更新但它们都在不同的行上! (但他们有一个共同的@ManyToOne字段。)

我已尝试过乐观和悲观的锁定,但没有解决这个问题。 通过几个并发更新,我得到了这个错误。

0 个答案:

没有答案