AnsweredAssumed Answered

org.activiti.engine.ActivitiOptimisticLockingException: JobEntity

Question asked by soaguy on Dec 8, 2015
Latest reply on Dec 10, 2015 by jbarrez
Hi all,
         I have 2 Activiti (v5.18) engines instances pointed to the same database. I have a java delegate serviceTask that has async='true'.  The java delegate is straighforward as it just inserts a row to an application table. When I test will higher message count, I see this exception below.


org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=45926] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:294)
   at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:921)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:887)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:612)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:137)
   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 org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:69)
   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)


I understand the async step creates a job and the job is executed on a separate thread, but this is causing duplicate insertions into the app table. For example when I test with 50 messages, I see this exception in the log and sometimes 62 rows in the app table. The count on the ACT_HI_PROCINST is still 50 though. Can someone please explain what is going on and how to handle this?

Thanks
Clement

Outcomes