cancel
Showing results for 
Search instead for 
Did you mean: 

org.activiti.engine.ActivitiOptimisticLockingException: ProcessInstance[423472] was updated by another transaction concurrently

jdp
Confirmed Champ
Confirmed Champ
Hi,

I have a workflow designed as attached, when this workflow run in below mentioned steps, it is throwing  'org.activiti.engine.ActivitiOptimisticLockingException: ProcessInstance[423472] was updated by another transaction concurrently' error.

Step:
1. Tasks U1, S1, S2 are completed.
2. When system is going to complete U4, it calls S4 in same transaction.
3. During execution of S4, completion call for U2 is reached and trying to complete that task as well. So at this point activiti throws mentioned exception.

Trace :
        org.activiti.engine.ActivitiOptimisticLockingException: ProcessInstance[423472] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:621)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:503)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:175)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:122)
   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:131)
   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.TaskServiceImpl.complete(TaskServiceImpl.java:170)
         ……………


Can any one has any hints, how to solve the problem. I have resolved this problem by making same workflow instance calls in synch, but the solution does not work for environment which has multiple activiti engines running as these calls are coming from different activiti engines.

is there any way I can handle this situation other than making it in synch mode ?


JDP
3 REPLIES 3

jdp
Confirmed Champ
Confirmed Champ
Sorry not able to attach workflow image here.. as only .txt files are allowed.

jbarrez
Star Contributor
Star Contributor
That exception typically means that multiple threads are doing something to the process instance.
Do you have multiple engines running with job executor enabled?

Attach the process xml as txt to this post so we can see if there's something else up.

jdp
Confirmed Champ
Confirmed Champ
Hi jbarrez,

Thanks for the reply. Sorry I am replying too late but was stuck with something else.

As you mentioned, Yes there are multiple threads accessing same process instance. Actually completion calls for four different parallel nodes reaches at same time and one system task is already running, in this case this problem occurred.

I had solved this problem by making same instance calls in Synch, So now all calls of same process instance will execute sequentially.
Yes, I am using multiple Activiti engines, 2 for now. So I had applied Synch mechanism across all Activiti engines using distributed locking mechanism.

Now I am facing below mentioned problem frequently, please refer this case as well, however this case is related to multiple threads are accessing different process instance same time :
https://forums.activiti.org/content/deadlocked-while-deleting-records-actruexecution-multiple-activi...

Please provide your thoughts/suggestions for the same. Is this a right solutions for the situation ?

Thanks,
JDP