AnsweredAssumed Answered

JobEntity was updated by another transaction concurrently

Question asked by tomekzaremba on Feb 19, 2016
Latest reply on Nov 9, 2016 by vsk106@gmail.com
Hi,

during stress test of our application most of process instances failed because of exception:


org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=1301291] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:297)
   at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:924)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:890)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:615)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:138)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
   at pl.play.executor.ComLoggingExecuteAsyncRunnable.executeJob(ComLoggingExecuteAsyncRunnable.java:34)
   at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:50)
   at pl.play.executor.ComLoggingExecuteAsyncRunnable.run(ComLoggingExecuteAsyncRunnable.java:25)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)


Retries counter for jobs met -1 and about 80% of started process instances freezes.
All jobs that failed are exclusive and are starting async serviceTasks.

Our architecture contains two Activiti based applications connected to same database. Both are using SpringAsyncExecutor to obtain new jobs. Most of the configuration is default for Activiti framework.

What are we doing wrong? Is Activiti not able to handle our use case to use async executor in multiple engines to process started instances?

Any help will be appreciated.

Outcomes