mysql - How to avoid javax.persistence.RollbackException: Transaction marked as rollbackOnly -
these specifications using in application
- spring 4.0.0
- spring data version 1.10.1.release
- aspect-j version 1.8.9
- spring-retry version 1.1.2.release
the problem facing exception associated concurrent transactions in spring data.
there many users logged in application @ same time , access 1 row of datbase table simultaneously.
inorder avoid dirty reads have used pessimistic locking in repository layer
, example
@lock(lockmodetype.pessimistic_write) wallet findone(long id);
and annotated methods transactional , annotated method @retryable
retrying method on exceptions, shown below
@transactional(isolation = isolation.read_committed, norollbackfor = {lockacquisitionexception.class}) @retryable(value = {lockacquisitionexception.class}, maxattempts = 5) public wallet dooperations() { ...... }
when multiple simultaneous hits occur on above method exceptions thrown follows:
2016-08-29 11:39:03 error [sqlexceptionhelper:logexceptions->146] - deadlock found when trying lock; try restarting transaction javax.persistence.rollbackexception: transaction marked rollbackonly
but need transaction re-execute , not throw exception shown below.
javax.persistence.rollbackexception: transaction marked rollbackonly
how can make happen spring configuration or need have manual work-around solve same?
thanks in advance!
Comments
Post a Comment