Cannot cancel a transaction with boundary cancel event
Description of the bug
I am using a straightforward workflow containing a transaction with a boundary cancel event, like in the image bellow.
The cancel is not working: the engine makes the following exception: org.flowable.common.engine.api.FlowableException: No execution found for sub process of boundary cancel event boundarycancel1.
Expected behavior When the Cancel End Event is triggered, the workflow should continue with the task "User task when canceled" and no exception should be thrown by the engine. It should work according to this piece of documentation : https://www.flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#cancel-end-event .
Code I had a look in the code. What basically happens is that the engine executes the org.flowable.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior first, for the Cancel End Event. During this processing, the transaction sub-process is marked as deleted. Later on, when the engine executes org.flowable.engine.impl.bpmn.behavior.BoundaryCancelEventActivityBehavior, it calls executionEntityManager.findChildExecutionsByProcessInstanceId(execution.getProcessInstanceId()) to find the transaction. The issue is that this search only looks only for non deleted executions, so the transaction is not found because it is already marked as deleted by the CancelEndEventActivityBehavior. Then the exception is thrown at BoundaryCancelEventActivityBehavior.java, line 60.
Additional context Using the Flowable engine version 6.7.1. We have just migrated from activiti 5.2 and we have lots of legacy workflows like this one. They were working fine with activiti but not working anymore with flowable. Also adding the bpmn file: TestTransactions.zip