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 (ExceptionHandlerAdvice.java:80) - Unhandled exception
org.activiti.engine.ActivitiOptimisticLockingException: ProcessInstance[1065194] was updated by another transaction concurrently
at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:875) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:614) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:138) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) ~[activiti-spring-5.19.0.2.jar:5.19.0.2]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) ~[activiti-spring-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:179) ~[activiti-engine-5.19.0.2.jar:5.19.0.2]
at org.activiti.rest.service.api.runtime.task.TaskResource.completeTask(TaskResource.java:126) ~[activiti-rest-5.19.0.2.jar:5.19.0.2]
at org.activiti.rest.service.api.runtime.task.TaskResource.executeTaskAction(TaskResource.java:78) ~[activiti-rest-5.19.0.2.jar:5.19.0.2]
at org.activiti.rest.service.api.runtime.task.TaskResource$$FastClassBySpringCGLIB$$96dfdb64.invoke(<generated>) ~[spring-core-4.0.5.RELEASE.jar:5.19.0.2]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[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).

Outcomes