Hello,
We have encountered the issue of receiving Optimistic Locking exception as we tried to delete a subprocess from another process.
Here is our environment settings:
Spring Boot: V2.1.2 RELEASE
Camunda BPM: v7.12.0
Camunda BPM Spring Boot Starter: v3.4.1
Database: Postgres v12
We have two Subprocesses namely Subprocess-1 and Subprocess-2. Subprocess-1 contains one user task, Subprocess-2 contains a timer and a service task. Subprocess-2 starts the timer when Subporcess-1 user task is assigned to a user. The issue we are facing is from time to time (not always), we’ve got Optimistic Locking exception when we tried to delete the running Subporcess-2 while completing Subprocess-1 user task.
Here is the code in Java Delegate implementation to delete the Subprocess-2
// Deleting the Subprocess -2
runtimeService.deleteProcessInstancesIfExists(processInstanceIds, "unassisgned user", true, true, false);
// Complete the Subprocess-1 user task
taskService.complete(userTask.getId());
Here is the error message we observed in the log:
org.camunda.bpm.engine.OptimisticLockingException:
ENGINE-03005 Execution of 'DELETE ExecutionEntity[f9a05d98-d0d1-11ea-a793-005056aeee74]' failed.
Entity was updated by another transaction concurrently.
Can you please let us know what might be the reason for the exception and how to fix it?
Thank you so much for your kind help in advance.