I am getting below deadlock exceptions in my application where I am using an embedded process engine and I have scaled my services to multiple instances.
Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.JobEntity.deleteTimer (batch index #8) failed. 7 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: (conn=4240878) Deadlock found when trying to get lock; try restarting transaction 19### Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.JobEntity.deleteTimer (batch index #8) failed. 7 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: (conn=4240878) Deadlock found when trying to get lock; try restarting transaction 20 at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) 21 at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:255) 22 at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.flushOperations(DbSqlSession.java:90) 23 at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:357) 24 … 15 common frames omitted 25Caused by: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.JobEntity.deleteTimer (batch index #8) failed. 7 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: (conn=4240878) Deadlock found when trying to get lock; try restarting transaction 26 at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:146) 27 at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:129) 28 at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:122) 29 at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114) 30 at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:253) 31 … 17 common frames omitted 32Caused by: java.sql.BatchUpdateException: (conn=4240878) Deadlock found when trying to get lock; try restarting transaction 33 at org.mariadb.jdbc.MariaDbStatement.executeBatchExceptionEpilogue(MariaDbStatement.java:309) 34 at org.mariadb.jdbc.ClientSidePreparedStatement.executeBatch(ClientSidePreparedStatement.java:293) 35 at sun.reflect.GeneratedMethodAccessor305.invoke(Unknown Source) 36 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 37 at java.lang.reflect.Method.invoke(Method.java:498) 38 at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) 39 at com.sun.proxy.$Proxy129.executeBatch(Unknown Source) 40 at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:122) 41 … 21 common frames omitted 42Caused by: java.sql.SQLTransactionRollbackException: (conn=4240878) Deadlock found when trying to get lock; try restarting transaction 43 at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:245) 44 at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:164) 45 at org.mariadb.jdbc.MariaDbStatement.executeBatchExceptionEpilogue(MariaDbStatement.java:305) 46 … 28 common frames omitted 47Caused by: java.sql.SQLException: Deadlock found when trying to get lock; try restarting transaction 48 at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1599) 49 at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1461) 50 at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1424) 51 at org.mariadb.jdbc.internal.protocol.AsyncMultiRead.call(AsyncMultiRead.java:149) 52 at org.mariadb.jdbc.internal.protocol.AsyncMultiRead.call(AsyncMultiRead.java:67)
Can anyone help with this?