AnsweredAssumed Answered

Activiti Optimistic Lock in Cluster creating multiple tasks !

Question asked by sunilkumartk on Sep 17, 2017

I am running activiti-rest on 2 cluster jboss nodes. My application initiates a simple workflow. with about 3 user tasks in it. I also have a few process instance variables in the workflow. 


I use the activiti-test/task/{taskId} api to complete user tasks. But occasionally the complete requests fails with the below exception.

ERROR | exception.ExceptionHandlerAdvice ( - Unhandled exception
org.activiti.engine.ActivitiOptimisticLockingException: ProcessInstance[1065194] was updated by another transaction concurrently
at org.activiti.engine.impl.db.DbSqlSession.flushUpdates( ~[activiti-engine-]
at org.activiti.engine.impl.db.DbSqlSession.flush( ~[activiti-engine-]
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions( ~[activiti-engine-]
at org.activiti.engine.impl.interceptor.CommandContext.close( ~[activiti-engine-]
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute( ~[activiti-engine-]
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction( ~[activiti-spring-]
at ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.activiti.spring.SpringTransactionInterceptor.execute( ~[activiti-spring-]
at org.activiti.engine.impl.interceptor.LogInterceptor.execute( ~[activiti-engine-]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute( ~[activiti-engine-]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute( ~[activiti-engine-]
at org.activiti.engine.impl.TaskServiceImpl.complete( ~[activiti-engine-]
at ~[activiti-rest-]
at ~[activiti-rest-]
at$$FastClassBySpringCGLIB$$96dfdb64.invoke(<generated>) ~[spring-core-4.0.5.RELEASE.jar:]
at org.springframework.cglib.proxy.MethodProxy.invoke( ~[spring-core-4.0.5.RELEASE.jar:4.0.5.RELEASE]


I am prepared to handle this error as there may have been a Activiti Lock Exception. 

But when i check the table i see that this exception has created two tasks. at times there two different type of tasks (in act_ru_tasks) table. fro eg: while trying to complete 'firstTask', the next task 'secondTask' is created but 'firstTask' row is still not deleted. I see similar issues in act_hi_taskinst table also.


In a similer situation i see that sometimes, i see multiple variables with same name per process instance in act_run_variable table.. Causing more confusion.


Can anyone suggest how this is possible ?



Notes: Activiti version used 5.19, Database: Oracle, 2 node cluster, running on WildFly8 (Jboss).