I'm seeing MySql Deadlocks with concurrent worker threads: [JDBCExceptionReporter] Deadlock found when trying to get lock; try restarting transaction

Solution Verified - Updated -

Issue

  • Severe problems are occuring when concurrent worker threads read and manipulate entities at the same time. How do I handle these deadlocks?

    WARN [JDBCExceptionReporter] SQL Error: 1213, SQLState: 40001
    ERROR [JDBCExceptionReporter] Deadlock found when trying to get lock; try restarting transaction
    ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
    org.hibernate.exception.LockAcquisitionException: Could not execute JDBC batch update
            at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:105)
            at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
            at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
            at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
            at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
            at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
            at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
            at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)
            at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
            at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)
            at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
            at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
            at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)
            at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)
            at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
            at org.jboss.ejb3.tx.UserTransactionImpl.commit(UserTransactionImpl.java:85)
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.0
  • Hibernate
    • 3.3.2
  • Java Persistence API (JPA)
  • MySQL 5 with InnoDb

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content