Optimistic Lock Exception

Hi, I’m trying to optimise a BPMN workflow by making subprocesses run in parallel instead of in series. After making our Feasibility Check and Reserve subprocess run in parallel after checking Multi Instance Asynchronous Before/Exclusive, we encountered the infamous Optimistic Lock Exception.

Would anyone be able to help me understand what might be causing the exception and how to troubleshoot and, ideally, resolve? I’ve been through the documentation but can’t make sense of it in our use case.

The Feasibility Check and Reserve subprocess is invoked as a multi instance with a collection of 5 ‘serviceRequests’ so I understand 5 instances are created. Orginally, these ran sequentially but the task inside the subprocess takes 2 minutes to run and so in series this is unacceptable.

I changed the sub-process to run Asynchronous Before with Exclusive disabled. Now the tasks inside the subprocess run in parallel however when the second instance returns to Camunda, an optimistic locking exception is thrown. The task ‘Update Activation Timeout’ doesn’t appear to run for any of the instances.

E2EMDIOBookingProcess.bpmn (94.3 KB)

2019-02-14T05:49:18.520Z|521093b1-1ada-40ac-a6f1-8486234dbf34|ENGINE-14006 Exception while executing job 2bc1f5e0-301c-11e9-8a11-0e49319a113b:
org.camunda.bpm.engine.OptimisticLockingException: ENGINE-03005 Execution of ‘UPDATE VariableInstanceEntity[27ab3627-301c-11e9-8a11-0e49319a113b]’ failed. Entity was updated by another transaction concurrently.
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.concurrentUpdateDbEntityException(EnginePersistenceLogger.java:125) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.handleOptimisticLockingException(DbEntityManager.java:342) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:308) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:281) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:203) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:132) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:113) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) ~[camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:36) [camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:29) [camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:88) [camunda-engine-7.7.0.jar:7.7.0]
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:57) [camunda-engine-7.7.0.jar:7.7.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_191]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]

@simoncoz which database are you using for camunda???

@aravindhrs it is MariaDB.