AnsweredAssumed Answered

JobEntity [id=*****] was updated by another transaction concurrently

Question asked by abhitorem on Feb 10, 2018
Latest reply on Feb 14, 2018 by ryandawson

activiti-springactiviti 5 jobexecutor 

Hi Team,

   In our Application, we are using Spring Boot with Activiti Rest 5.22.x Process Engine. We created workflow which have a Service Task with marked# Async as true calling the Class through the DelegateExpression Attribute by injecting the Spring Bean. On execution when control comes to the Service Task, ProcessEngine is creating a Job in the Act_ru_job table and it is not getting executed and eventually throwing the below exception in the console.

20180210 12:10:07.573 [pool-1-thread-2] ERROR org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable - exception during job execution: JobEntity [id=852513] was updated by another transaction concurrently
org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=852513] was updated by another transaction concurrently
     at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:295) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:897) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:890) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:617) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:138) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) ~[activiti-spring-5.22.0.jar:5.22.0]
     at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.3.8.RELEASE.jar:4.3.8.RELEASE]
     at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) ~[activiti-spring-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) ~[activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.handleMultipleJobs(ExecuteJobsRunnable.java:94) [activiti-engine-5.22.0.jar:5.22.0]
     at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:49) [activiti-engine-5.22.0.jar:5.22.0]
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
     at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
20180210 12:10:07.573 [pool-1-thread-2] DEBUG org.activiti.engine.impl.interceptor.LogInterceptor -

When i re-run the Job manually using the API /management/jobs/*** which it gets executed successfully.  

There is no issue when i run the same workflow in my Local, but gets failed when run in the Clustered Environment(Dev). 

We've set the JobExecutor to true in the config bean show as below:

SpringProcessEngineConfiguration processEngineConfig = new SpringProcessEngineConfiguration();
processEngineConfig.setDataSource(activitiDataSource());
processEngineConfig.setDatabaseSchemaUpdate("true");
processEngineConfig.setTransactionManager(activitiTransactionManager());
processEngineConfig.setJobExecutorActivate(true);

Can anybody help me understand why this happening.! 

 

Outcomes