Optimistic Locking issue while Deleting Sub-process

Hello,

Spring-Boot: (v2.1.2.RELEASE)
Camunda BPM: (v7.12.0)
Camunda BPM Spring Boot Starter: (v3.4.1)

I have two Subprocesses namely Subprocess-1 and Subprocess-2.

Subprocess-1 contains one user task, Subprocess-2 contains timer and it is used to start timer when Subporcess-1 user task get assigned by a user.

I am facing Optimistic locking issue when I try to delete the Subporcess-2 while performing Subprocess-1 user task complete API.

subProcess_2.bpmn (3.8 KB) subprocess-1.bpmn (2.1 KB)

runtimeService.deleteProcessInstancesIfExists(processInstanceIds, "unassisgned user", true, true, false); // Deleting the Subprocess -2
taskService.complete(userTask.getId()); // Complete the Subprocess-1 user task

Error occured while deleting the process Instance org.camunda.bpm.engine.OptimisticLockingException: ENGINE-03005 Execution of 'DELETE ExecutionEntity[f9a05d98-d0d1-11ea-a793-005056aeee74]' failed. Entity was updated by another transaction concurrently.

Any ideas to fix this issue.

Thanks,
Gokulnath