AnsweredAssumed Answered

Parallel task completion issue

Question asked by mpradny on May 2, 2013
Latest reply on Aug 27, 2013 by touseefrafique

I recently ran into a issue where two users completed one task at same time.  Process after this task is rather complex, including parallel gateways and call activities, where some data are updated in external system, so it runs for 20-30 seconds.

Problem is that when two users completed this task within 5 seconds, one failed due to data inconsistency in external system (which is expected), but also the first one failed with OptimisticLockingException

org.activiti.engine.ActivitiOptimisticLockingException: TaskEntity[13195361] was updated by another transaction concurrently
at org.activiti.engine.impl.db.DbSqlSession$DeletePersistentObjectOperation.execute(
at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(
at org.activiti.engine.impl.db.DbSqlSession.flush(
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(
at org.activiti.engine.impl.interceptor.CommandContext.close(

This is on Activiti 5.11 on Oracle.

I would expect that first execution would survive correctly. I don't know whether it is more db or activiti issue and only idea I have is to create some locking mechanism in application that would block such calls or claim task for individual user before calling task complete, but since the users are not used to claiming task I could get into problems when complete fails and task got stuck on individual user.

Any idea for some clean solution is welcomed :)