We have a java delegate to make rest calls to microservices. When doing a parallel multiinstance activity I can see that the tasks are being done in parallel, and both complete successfully. But when the 2nd task completes I get the optimistic locking error :
org.camunda.bpm.engine.OptimisticLockingException: ENGINE-03005 Execution of 'UPDATE VariableInstanceEntity[7730a196-615a-11ed-994e-0242a410105b]' failed. Entity was updated by another transaction concurrently.
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.concurrentUpdateDbEntityException(EnginePersistenceLogger.java:141)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.handleConcurrentModification(DbEntityManager.java:413)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:356)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:323)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:295)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:272)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:188)
When I look up that variable in the database this is what I get :
id_ rev_ type_ name_
--------------------------------------|--------|--------|-----------------------------------
7730a196-615a-11ed-994e-0242a410105b 2 integer nrOfCompletedInstances
Why am I getting an optimistic lock exception on a variable that is used only for multi instance tasks?