The service tasks are executed exactly in same time, in same millisecond, so optimistic locking is not the reason why they are executed twice.
I upgraded the Camunda from 7.9 to 7.12, it didn’t solve the issue.
Service task they use JavaDelegate interface.
The process is running asynchronously. parallel_service_tasks.bpmn (14.3 KB) versLesEtoilescase0.cmmn (4.7 KB)
When process is not parallel then service task is executed just one time as expected.
I fixed the warnings. The result is same.
Is there somewhere any Camunda source code available which activates the JavaDelegate interface?
I would investigate this part.
Finally i found the problem.
We are using one json variable where we keep all process data.
Now when service tasks were executed parallely then the last service task overwrote previous parallel service task data and Camunda process engine executed the previous parallel service task again because it was like never-ever executed.
Finally, these settings solved my issue when building BPMN schema in Java:
serviceTask.setCamundaAsyncBefore(true); serviceTask.setCamundaAsyncAfter(true); serviceTask.setCamundaExclusive(true); // this is avoiding to run parallel service tasks same time, otherwise i got error ENGINE-03005 Execution of ‘UPDATE VariableInstanceEntity[6f21f3f8-e8fc-11ea-8ae0-0242ac12000b]’ failed. Entity was updated by another transaction concurrently