Deadlock detected while trying to get a lock; try restarting the transaction: @RetryTransaction

I am working on Java Spring Hibernate Project with mysql.

I am trying to do some kind of insertion in a cascade. Jobs are placed on the cluster, so they can occur almost simultaneously, so there is a problem with locking.

I have this error:

Deadlock detected while trying to get a lock; try restarting the transaction

I found here that there is @RetryTransaction for Spring developper. The setting method is here .

They say that:

The method class must be gossiped (either at build time or at run time) using the AspectJ compiler with the RetryTransactionAspect aspect (included in the JAR file for dellroad-stuff).

What does it mean?

But I can't get it to work. It never restarts a transaction. What am I missing?

Thanks!

@Override @RetryTransaction @Transactional public void save(AnalyseResult analyseResult){ @SuppressWarnings("deprecation") final int attempt = RetryTransactionAspect.getAttempt(); System.out.println("#############"); System.out.println("Retry Transact : "+attempt); System.out.println("#############"); analyseResultDao.save(analyseResult); } 

In my BeanConfig.xml:

 <bean class="org.dellroad.stuff.spring.RetryTransactionAspect" factory-method="aspectOf"> <property name="persistenceExceptionTranslator" ref="hibernateExceptionTranslator"> </property> <property name="maxRetriesDefault" value="4"></property> <property name="initialDelayDefault" value="25"></property> <property name="maximumDelayDefault" value="5000"></property> </bean> 
0
java spring mysql hibernate deadlock
source share

No one has answered this question yet.

See similar questions:

214
How to avoid the mysql deadlock found when trying to get a lock; try restarting transaction "

or similar:

214
How to avoid the mysql deadlock found when trying to get a lock; try restarting transaction "
210
Getting timed out waiting for lock wait, attempting to restart a transaction, although I am not using a transaction
28
Getting "Deadlock detected while trying to block, try restarting the transaction"
25
Work on MySQL error "Deadlock detected while trying to get a lock, try restarting the transaction"
twenty
How to restart transactions at deadlock / timeout lock in Spring?
7
Does Hibernate automatically restart transactions when deadlocked?
2
Mysql subordinate command error: deadlock detected while trying to get a lock; try restarting the transaction
one
Getting a "Dead End" detected when trying to get a lock; try restarting transaction "
0
A deadlock was detected while trying to get a lock; try restarting the transaction;
0
Mysql: Deadlock detected while trying to get a lock; try restarting the transaction

All Articles