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(
   at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(
   at org.activiti.engine.impl.db.DbSqlSession.flush(
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(
   at org.activiti.engine.impl.interceptor.CommandContext.close(
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(
   at org.activiti.spring.SpringTransactionInterceptor.execute(
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(
   at java.util.concurrent.ThreadPoolExecutor.runWorker(
   at java.util.concurrent.ThreadPoolExecutor$

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?