AnsweredAssumed Answered

ActivitiOptimisticException with single JobExecutor

Question asked by sushantmahajan on Feb 10, 2015
Latest reply on Feb 24, 2015 by trademak
We have written a custom code overriding Locking for jobs in acquireJobCmd. The application uses Hibernate for database connection. Sometimes we experience ActivitiOptimisticLockingException for a job and that job gets stuck with a lock owner till it reaches lock expiration time. The exception that occurs is:

ERROR pool-1-thread-5 org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable - exception during job execution: ProcessInstance[d108d1cf-ada6-11e4-9e28-c2e2b6a89800] was updated by another transaction concurrently
org.activiti.engine.ActivitiOptimisticLockingException: ProcessInstance[d108d1cf-ada6-11e4-9e28-c2e2b6a89800] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:777)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:588)
   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:130)
   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.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:52)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

We have not accessed that job/process instance other after locking it. What may be the reason we get this Exception even when we are on Single Server environment?

Outcomes