In a process definition we were using a delegate class as an execution listener on a service task that called a different delegate class. This seems to fork the execution in the process instance and cause two different executions to continue on through the process instance. This created a race condition where sometimes the different executions would try to update the DB and fail due to a foreign key constraint missing. (This seems to happen while exiting a call activity later in the workflow.)
We have removed the listener and set it up to run as its own service task, which has cleared up the problem, but I have a couple of questions:
- Why is this allowed to happen? It seems like some safeguard should have prevented this state.
- When this happens, is there any way to clean up the the process instance?
- The process definition has a cancel handler, so I triggered a cancel signal, but then that had a call activity and dead locked on the DB updates again.
- I tried to delete the workflow using the runtime service
deleteProcessInstance
function but that throws aTooManyResultsException
when it gets multiple executions back for the process instance.
I looked for a way to kill one of the executions, but could not find one.