cancel
Showing results for 
Search instead for 
Did you mean: 

Asynchronous task/transaction cancelation

vanquis
Champ in-the-making
Champ in-the-making
Hello all,

I'm using Activiti 5.18 with Oracle DB. I'm trying to implement asynchronous cancel for subprocesses (transactions) and I have encountered a problem with DB constraint.
Here is the stack trace:

org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: naruszono więzy spójności (VANQUIS.ACT_FK_TASK_EXE) - znaleziono rekord podrzędny

### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: naruszono więzy spójności (VANQUIS.ACT_FK_TASK_EXE) - znaleziono rekord podrzędny

   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:150)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:161)
   at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:292)
   at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:921)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:887)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:612)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:137)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
   at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:175)
   at SignalBoundaryCancelSubprocess.main(SignalBoundaryCancelSubprocess.java:79)
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: naruszono więzy spójności (VANQUIS.ACT_FK_TASK_EXE) - znaleziono rekord podrzędny

   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
   at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
   at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
   at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
   at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
   at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
   at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:208)
   at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1046)
   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
   at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3613)
   at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3714)
   at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1378)
   at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
   at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
   at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
   at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
   at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
   … 13 more


It appears when using tools marked as experimental (CancelEndEvent + transaction subprocess + CancelBoundaryEvent) as well as while using just simple IntermediateSignalThrowingEvent + SignalCatching boundary event with cancelActivity="true" on a transaction subprocess. The error occurs, when the cancel signal comes and I have still a UserTask opened in progress inside the subprocess. My guess is that the cancel just goes straight into the DB and tries to delete the execution without any status checking, despite the fact that there is still a Task in progress. Probably the key is that 2 actions are going in parallel here (async=true, exlusive=false).

To achieve the behavior described above I'm using a parallel gateway in order to fork the execution into 2 concurrent branches. Then one branch asynchronically sends interrupt to the other one.

I've got 3 questions:
1. Am I doing something wrong here?
2. Is it a bug or asynchronous cancels are just not supported yet?
3. If there is another way to asynchronously cancel an ongoing activity, could You please tell me what it is?

Here is my bpmn:

<?xml version='1.0' encoding='UTF-8'?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
  <signal id="interrupt" name="Interrupt" activiti:scope="global"/>
  <process id="SimpleCancel" name="SimpleCancel" isExecutable="true">
    <startEvent id="startprocess"/>
    <userTask id="initialtask" name="InitialTask"/>
    <parallelGateway id="parallelgateway"/>
    <userTask id="interrupttask" name="InterruptTask" activiti:async="true" activiti:exclusive="false"/>
    <intermediateThrowEvent id="cancelsignalthrow">
      <signalEventDefinition signalRef="interrupt"/>
    </intermediateThrowEvent>
    <transaction id="subprocess" name="subProcess">
      <startEvent id="startsubprocess"/>
      <userTask id="firsttask" name="FirstTask" activiti:async="true" activiti:exclusive="false"/>
      <endEvent id="endsubprocess"/>
      <sequenceFlow id="s6" sourceRef="startsubprocess" targetRef="firsttask"/>
      <sequenceFlow id="s7" sourceRef="firsttask" targetRef="endsubprocess"/>
    </transaction>
    <userTask id="aftercancel" name="AfterCancel" activiti:async="true" activiti:exclusive="false"/>
    <userTask id="finaltask" name="FinalTask" activiti:async="true" activiti:exclusive="false"/>
    <endEvent id="endprocess"/>
    <sequenceFlow id="s1" sourceRef="startprocess" targetRef="initialtask"/>
    <sequenceFlow id="s2" sourceRef="initialtask" targetRef="parallelgateway"/>
    <sequenceFlow id="s3" sourceRef="parallelgateway" targetRef="subprocess"/>
    <sequenceFlow id="s4" sourceRef="parallelgateway" targetRef="interrupttask"/>
    <sequenceFlow id="s5" sourceRef="interrupttask" targetRef="cancelsignalthrow"/>
    <sequenceFlow id="s8" sourceRef="subprocess" targetRef="finaltask"/>
    <sequenceFlow id="s9" sourceRef="finaltask" targetRef="endprocess"/>
    <sequenceFlow id="s10" sourceRef="cancelboundarysignalcatch" targetRef="aftercancel"/>
    <sequenceFlow id="s11" sourceRef="aftercancel" targetRef="endprocess"/>
    <boundaryEvent id="cancelboundarysignalcatch" attachedToRef="subprocess" cancelActivity="true">
      <signalEventDefinition signalRef="interrupt"/>
    </boundaryEvent>
  </process>

  <bpmndi:BPMNDiagram id="BPMNDiagram_SimpleCancel">
    <bpmndi:BPMNPlane bpmnElement="SimpleCancel" id="BPMNPlane_SimpleCancel">
      <bpmndi:BPMNShape bpmnElement="startprocess" id="BPMNShape_startprocess">
        <omgdc:Bounds height="30.0" width="30.0" x="96.63336181640625" y="244.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="initialtask" id="BPMNShape_initialtask">
        <omgdc:Bounds height="80.0" width="100.0" x="186.63336181640625" y="219.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway" id="BPMNShape_parallelgateway">
        <omgdc:Bounds height="40.0" width="40.0" x="375.0" y="239.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="interrupttask" id="BPMNShape_interrupttask">
        <omgdc:Bounds height="80.0" width="100.0" x="345.0" y="345.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="cancelsignalthrow" id="BPMNShape_cancelsignalthrow">
        <omgdc:Bounds height="30.0" width="30.0" x="380.0" y="519.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess" id="BPMNShape_subprocess">
        <omgdc:Bounds height="160.0" width="278.0" x="538.6333618164062" y="179.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startsubprocess" id="BPMNShape_startsubprocess">
        <omgdc:Bounds height="30.0" width="30.0" x="555.0" y="244.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="firsttask" id="BPMNShape_firsttask">
        <omgdc:Bounds height="80.0" width="100.0" x="629.6333618164062" y="219.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endsubprocess" id="BPMNShape_endsubprocess">
        <omgdc:Bounds height="28.0" width="28.0" x="774.6333618164062" y="245.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="aftercancel" id="BPMNShape_aftercancel">
        <omgdc:Bounds height="80.0" width="100.0" x="784.6333618164062" y="434.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="finaltask" id="BPMNShape_finaltask">
        <omgdc:Bounds height="80.0" width="100.0" x="861.6333618164062" y="219.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endprocess" id="BPMNShape_endprocess">
        <omgdc:Bounds height="28.0" width="28.0" x="1006.6333618164062" y="245.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="cancelboundarysignalcatch" id="BPMNShape_cancelboundarysignalcatch">
        <omgdc:Bounds height="30.0" width="30.0" x="753.4867711020827" y="324.28905936873736"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="s2" id="BPMNEdge_s2">
        <omgdi:waypoint x="286.63336181640625" y="259.15703866929493"/>
        <omgdi:waypoint x="375.43594746690496" y="259.43594746690496"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s1" id="BPMNEdge_s1">
        <omgdi:waypoint x="126.63336181640625" y="259.0"/>
        <omgdi:waypoint x="186.63336181640625" y="259.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s9" id="BPMNEdge_s9">
        <omgdi:waypoint x="961.6333618164062" y="259.0"/>
        <omgdi:waypoint x="1006.6333618164062" y="259.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s7" id="BPMNEdge_s7">
        <omgdi:waypoint x="729.6333618164062" y="259.0"/>
        <omgdi:waypoint x="774.6333618164062" y="259.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s8" id="BPMNEdge_s8">
        <omgdi:waypoint x="816.6333618164062" y="259.0"/>
        <omgdi:waypoint x="861.6333618164062" y="259.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s5" id="BPMNEdge_s5">
        <omgdi:waypoint x="395.0" y="425.0"/>
        <omgdi:waypoint x="395.0" y="519.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s6" id="BPMNEdge_s6">
        <omgdi:waypoint x="585.0" y="259.0"/>
        <omgdi:waypoint x="629.6333618164062" y="259.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s10" id="BPMNEdge_s10">
        <omgdi:waypoint x="775.0981386803538" y="352.75345013642476"/>
        <omgdi:waypoint x="814.9923169526834" y="434.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s3" id="BPMNEdge_s3">
        <omgdi:waypoint x="414.5337317991687" y="259.4662682008313"/>
        <omgdi:waypoint x="538.6333618164062" y="259.24633740424224"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s11" id="BPMNEdge_s11">
        <omgdi:waypoint x="869.2380129791969" y="434.0"/>
        <omgdi:waypoint x="1011.4737120077149" y="269.5877672519819"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s4" id="BPMNEdge_s4">
        <omgdi:waypoint x="395.424" y="278.576"/>
        <omgdi:waypoint x="395.1593625498008" y="345.0"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


Here is also the simple process diagram:
[img]http://i.imgur.com/l6WrsFj.png[/img]

I'm looking forward to Your help.

Regards,
Vanquis
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Hi Vanquis,

It looks like a bug. Could you create a unit test project showing the issue? That would make it easier for us to reproduce the issue and to solve it.

Best regards,

vanquis
Champ in-the-making
Champ in-the-making
Thank You for Your reply. I couldn't add the .zip archive with unit test as an attachment here due to .txt format restrictions, so I've hosted it on a file upload server:
http://www.filedropper.com/simple-cancel-unit-test
It's exacly the same process as the one shown on the diagram in my post above.

I've also made some digging and experiments around the problem and I have managed to create some kind of temporary workaround for this bug using ActivityBehavior. It looks like this:
[IMG]http://i.imgur.com/TjaL3ZT.png[/IMG]

And the bmpn20.xml file looks like this:
<code>
<?xml version='1.0' encoding='UTF-8'?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
  <signal id="interrupt" name="Interrupt" activiti:scope="global"/>
  <signal id="trigger" name="Trigger" activiti:scope="global"/>
  <process id="process" isExecutable="true">
    <startEvent id="startprocess"/>
    <userTask id="initialtask" name="InitialTask"/>
    <transaction id="subprocess" name="subProcess">
      <startEvent id="startsubprocess"/>
      <parallelGateway id="parallelsignalfork"/>
      <userTask id="firsttask" name="FirstTask" activiti:async="true" activiti:exclusive="false"/>
      <exclusiveGateway id="firstexclusive"/>
      <userTask id="secondtask" name="SecondTask" activiti:async="true" activiti:exclusive="false"/>
      <exclusiveGateway id="secondexclusive"/>
      <intermediateCatchEvent id="interruptsignalcatch">
        <signalEventDefinition signalRef="interrupt"/>
      </intermediateCatchEvent>
      <serviceTask id="interrupthandler" name="InterruptHandler" activiti:async="true" activiti:exclusive="false" activiti:class="ExperimentalExecutionDeactivator"/>
      <userTask id="thirdtask" name="ThirdTask" activiti:async="true" activiti:exclusive="false"/>
      <exclusiveGateway id="thirdexclusive"/>
      <endEvent id="endsubprocess"/>
      <endEvent id="cancelendsubprocess">
        <cancelEventDefinition/>
      </endEvent>
      <boundaryEvent id="firstboundarycompevent" attachedToRef="firsttask" cancelActivity="false">
        <compensateEventDefinition/>
      </boundaryEvent>
      <boundaryEvent id="thirdboundarycompevent" attachedToRef="thirdtask" cancelActivity="false">
        <compensateEventDefinition/>
      </boundaryEvent>
      <serviceTask id="firstcomp" name="FirstComp" activiti:class="FirstCompensationAction"/>
      <serviceTask id="secondcomp" name="SecondComp" activiti:class="SecondCompensationAction"/>
      <serviceTask id="thirdcomp" name="ThirdComp" activiti:class="ThirdCompensationAction"/>
      <boundaryEvent id="secondboundarycompevent" attachedToRef="secondtask" cancelActivity="false">
        <compensateEventDefinition/>
      </boundaryEvent>
      <intermediateThrowEvent id="triggersignalthrow">
        <signalEventDefinition signalRef="trigger"/>
      </intermediateThrowEvent>
      <intermediateCatchEvent id="triggersignalcatch">
        <signalEventDefinition signalRef="trigger"/>
      </intermediateCatchEvent>
      <userTask id="waitstate" name="WaitState" activiti:async="true" activiti:exclusive="false"/>
      <intermediateCatchEvent id="timer">
        <timerEventDefinition>
          <timeDuration>P5S</timeDuration>
        </timerEventDefinition>
      </intermediateCatchEvent>
      <sequenceFlow id="s3" sourceRef="startsubprocess" targetRef="parallelsignalfork"/>
      <sequenceFlow id="s13" sourceRef="parallelsignalfork" targetRef="interruptsignalcatch"/>
      <sequenceFlow id="s14" sourceRef="interruptsignalcatch" targetRef="interrupthandler"/>
      <sequenceFlow id="s4" sourceRef="parallelsignalfork" targetRef="firsttask"/>
      <sequenceFlow id="s8" sourceRef="secondexclusive" targetRef="thirdtask">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isInterrupted == 0}]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="s10" sourceRef="thirdexclusive" targetRef="endsubprocess">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isInterrupted == 0}]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="s9" sourceRef="thirdtask" targetRef="thirdexclusive"/>
      <sequenceFlow id="s7" sourceRef="secondtask" targetRef="secondexclusive"/>
      <sequenceFlow id="s5" sourceRef="firsttask" targetRef="firstexclusive"/>
      <sequenceFlow id="s6" sourceRef="firstexclusive" targetRef="secondtask">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isInterrupted == 0}]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="s23" sourceRef="triggersignalcatch" targetRef="cancelendsubprocess"/>
      <sequenceFlow id="s15" sourceRef="firstexclusive" targetRef="triggersignalcatch">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isInterrupted == 1}]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="s16" sourceRef="secondexclusive" targetRef="triggersignalcatch">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isInterrupted == 1}]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="s17" sourceRef="thirdexclusive" targetRef="triggersignalcatch">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isInterrupted == 1}]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="s20" sourceRef="interrupthandler" targetRef="waitstate"/>
      <sequenceFlow id="s22" sourceRef="timer" targetRef="triggersignalthrow"/>
      <sequenceFlow id="s21" sourceRef="waitstate" targetRef="timer"/>
    </transaction>
    <userTask id="finaltask" name="FinalTask"/>
    <endEvent id="endprocess"/>
    <userTask id="aftercancel" name="AfterCancel"/>
    <sequenceFlow id="s1" sourceRef="startprocess" targetRef="initialtask"/>
    <sequenceFlow id="s2" sourceRef="initialtask" targetRef="subprocess"/>
    <boundaryEvent id="cancelboundary" attachedToRef="subprocess" cancelActivity="false">
      <cancelEventDefinition/>
    </boundaryEvent>
    <sequenceFlow id="s18" sourceRef="cancelboundary" targetRef="aftercancel"/>
    <sequenceFlow id="s11" sourceRef="subprocess" targetRef="finaltask"/>
    <sequenceFlow id="s12" sourceRef="finaltask" targetRef="endprocess"/>
    <sequenceFlow id="s19" sourceRef="aftercancel" targetRef="endprocess"/>
    <association id="a1" sourceRef="firstboundarycompevent" targetRef="firstcomp"/>
    <association id="a2" sourceRef="secondboundarycompevent" targetRef="secondcomp"/>
    <association id="a3" sourceRef="thirdboundarycompevent" targetRef="thirdcomp"/>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_process">
    <bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_process">
      <bpmndi:BPMNShape bpmnElement="startprocess" id="BPMNShape_startprocess">
        <omgdc:Bounds height="30.0" width="30.0" x="105.0" y="272.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="initialtask" id="BPMNShape_initialtask">
        <omgdc:Bounds height="80.0" width="100.0" x="173.5" y="247.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess" id="BPMNShape_subprocess">
        <omgdc:Bounds height="454.0" width="981.1333618164062" x="315.0" y="60.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startsubprocess" id="BPMNShape_startsubprocess">
        <omgdc:Bounds height="30.0" width="30.0" x="330.0" y="122.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelsignalfork" id="BPMNShape_parallelsignalfork">
        <omgdc:Bounds height="40.0" width="40.0" x="402.0" y="117.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="firsttask" id="BPMNShape_firsttask">
        <omgdc:Bounds height="80.0" width="100.0" x="520.0" y="97.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="firstexclusive" id="BPMNShape_firstexclusive">
        <omgdc:Bounds height="40.0" width="40.0" x="665.0" y="117.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="secondtask" id="BPMNShape_secondtask">
        <omgdc:Bounds height="80.0" width="100.0" x="750.0" y="97.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="secondexclusive" id="BPMNShape_secondexclusive">
        <omgdc:Bounds height="40.0" width="40.0" x="895.0" y="117.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="interruptsignalcatch" id="BPMNShape_interruptsignalcatch">
        <omgdc:Bounds height="30.0" width="30.0" x="407.0" y="240.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="interrupthandler" id="BPMNShape_interrupthandler">
        <omgdc:Bounds height="78.0" width="124.0" x="360.0" y="375.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="thirdtask" id="BPMNShape_thirdtask">
        <omgdc:Bounds height="80.0" width="100.0" x="980.0" y="97.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="thirdexclusive" id="BPMNShape_thirdexclusive">
        <omgdc:Bounds height="40.0" width="40.0" x="1125.0" y="117.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endsubprocess" id="BPMNShape_endsubprocess">
        <omgdc:Bounds height="28.0" width="28.0" x="1210.0" y="123.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="cancelendsubprocess" id="BPMNShape_cancelendsubprocess">
        <omgdc:Bounds height="28.0" width="28.0" x="901.0" y="450.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="firstboundarycompevent" id="BPMNShape_firstboundarycompevent">
        <omgdc:Bounds height="30.0" width="30.0" x="574.642276708615" y="162.05753348653252"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="thirdboundarycompevent" id="BPMNShape_thirdboundarycompevent">
        <omgdc:Bounds height="30.0" width="30.0" x="1038.1291695212553" y="162.05397627655617"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="firstcomp" id="BPMNShape_firstcomp">
        <omgdc:Bounds height="80.0" width="100.0" x="539.642276708615" y="255.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="secondcomp" id="BPMNShape_secondcomp">
        <omgdc:Bounds height="80.0" width="100.0" x="770.6915450469849" y="255.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="thirdcomp" id="BPMNShape_thirdcomp">
        <omgdc:Bounds height="80.0" width="100.0" x="1003.1291695212553" y="255.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="secondboundarycompevent" id="BPMNShape_secondboundarycompevent">
        <omgdc:Bounds height="30.0" width="30.0" x="805.6915450469849" y="162.04809360404013"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="triggersignalthrow" id="BPMNShape_triggersignalthrow">
        <omgdc:Bounds height="30.0" width="30.0" x="645.0" y="465.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="triggersignalcatch" id="BPMNShape_triggersignalcatch">
        <omgdc:Bounds height="30.0" width="30.0" x="900.0" y="395.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="waitstate" id="BPMNShape_waitstate">
        <omgdc:Bounds height="80.0" width="100.0" x="510.0" y="374.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="timer" id="BPMNShape_timer">
        <omgdc:Bounds height="31.0" width="31.0" x="644.5" y="398.5"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="finaltask" id="BPMNShape_finaltask">
        <omgdc:Bounds height="80.0" width="100.0" x="1341.1333618164062" y="247.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endprocess" id="BPMNShape_endprocess">
        <omgdc:Bounds height="28.0" width="28.0" x="1530.0" y="273.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="aftercancel" id="BPMNShape_aftercancel">
        <omgdc:Bounds height="80.0" width="100.0" x="1054.12999609751" y="705.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="a1" id="BPMNShape_a1">
        <omgdc:Bounds height="61.57836085491607" width="0.0" x="589.642276708615" y="192.80034180071596"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="a2" id="BPMNShape_a2">
        <omgdc:Bounds height="61.58344954157212" width="0.0" x="820.6915450469849" y="192.79208190353512"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="a3" id="BPMNShape_a3">
        <omgdc:Bounds height="61.58027841341891" width="0.0" x="1053.1291695212553" y="192.79722924198666"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="cancelboundary" id="BPMNShape_cancelboundary">
        <omgdc:Bounds height="30.0" width="30.0" x="1089.12999609751" y="499.4735806750714"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="s9" id="BPMNEdge_s9">
        <omgdi:waypoint x="1080.0" y="137.2164502164502"/>
        <omgdi:waypoint x="1125.4130434782608" y="137.41304347826087"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="a1" id="BPMNEdge_a1">
        <omgdi:waypoint x="589.642276708615" y="192.05753348653252"/>
        <omgdi:waypoint x="589.642276708615" y="255.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="a2" id="BPMNEdge_a2">
        <omgdi:waypoint x="820.6915450469849" y="192.04809360404013"/>
        <omgdi:waypoint x="820.6915450469849" y="255.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="a3" id="BPMNEdge_a3">
        <omgdi:waypoint x="1053.1291695212553" y="192.05397627655617"/>
        <omgdi:waypoint x="1053.1291695212553" y="255.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s7" id="BPMNEdge_s7">
        <omgdi:waypoint x="850.0" y="137.2164502164502"/>
        <omgdi:waypoint x="895.4130434782609" y="137.41304347826087"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s23" id="BPMNEdge_s23">
        <omgdi:waypoint x="915.0" y="425.0"/>
        <omgdi:waypoint x="915.0" y="450.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s8" id="BPMNEdge_s8">
        <omgdi:waypoint x="934.5833333333334" y="137.41666666666666"/>
        <omgdi:waypoint x="980.0" y="137.2183406113537"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s21" id="BPMNEdge_s21">
        <omgdi:waypoint x="610.0" y="414.0"/>
        <omgdi:waypoint x="644.5" y="414.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s5" id="BPMNEdge_s5">
        <omgdi:waypoint x="620.0" y="137.2164502164502"/>
        <omgdi:waypoint x="665.4130434782609" y="137.41304347826087"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s22" id="BPMNEdge_s22">
        <omgdi:waypoint x="660.3778661538391" y="430.4995338470726"/>
        <omgdi:waypoint x="660.1145004807757" y="465.00043701836944"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s6" id="BPMNEdge_s6">
        <omgdi:waypoint x="704.5833333333334" y="137.41666666666666"/>
        <omgdi:waypoint x="750.0" y="137.2183406113537"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s3" id="BPMNEdge_s3">
        <omgdi:waypoint x="359.9996878349271" y="137.09677217958017"/>
        <omgdi:waypoint x="402.37012987012986" y="137.37012987012986"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s4" id="BPMNEdge_s4">
        <omgdi:waypoint x="441.5646258503401" y="137.43537414965985"/>
        <omgdi:waypoint x="520.0" y="137.16949152542372"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s20" id="BPMNEdge_s20">
        <omgdi:waypoint x="484.0" y="414.0"/>
        <omgdi:waypoint x="510.0" y="414.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s2" id="BPMNEdge_s2">
        <omgdi:waypoint x="273.5" y="287.0"/>
        <omgdi:waypoint x="315.0" y="287.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s1" id="BPMNEdge_s1">
        <omgdi:waypoint x="135.0" y="287.0"/>
        <omgdi:waypoint x="173.5" y="287.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s16" id="BPMNEdge_s16">
        <omgdi:waypoint x="915.4650735294117" y="156.53492647058823"/>
        <omgdi:waypoint x="915.027522889449" y="395.000025250336"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s17" id="BPMNEdge_s17">
        <omgdi:waypoint x="1145.5" y="156.5"/>
        <omgdi:waypoint x="1145.5" y="464.0"/>
        <omgdi:waypoint x="929.6045745164387" y="413.4214621426798"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s18" id="BPMNEdge_s18">
        <omgdi:waypoint x="1104.12999609751" y="529.4735806750714"/>
        <omgdi:waypoint x="1104.12999609751" y="705.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s19" id="BPMNEdge_s19">
        <omgdi:waypoint x="1154.12999609751" y="743.8282549302139"/>
        <omgdi:waypoint x="1534.911747153663" y="297.6491154656643"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s12" id="BPMNEdge_s12">
        <omgdi:waypoint x="1441.1333618164062" y="287.0"/>
        <omgdi:waypoint x="1530.0" y="287.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s13" id="BPMNEdge_s13">
        <omgdi:waypoint x="422.4188034188034" y="156.5811965811966"/>
        <omgdi:waypoint x="422.06382920933527" y="240.0001358062136"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s14" id="BPMNEdge_s14">
        <omgdi:waypoint x="422.0" y="270.0"/>
        <omgdi:waypoint x="422.0" y="375.0"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s15" id="BPMNEdge_s15">
        <omgdi:waypoint x="685.5" y="156.5"/>
        <omgdi:waypoint x="685.5" y="464.0"/>
        <omgdi:waypoint x="900.3987424749963" y="413.4355900058832"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s10" id="BPMNEdge_s10">
        <omgdi:waypoint x="1164.621794871795" y="137.37820512820514"/>
        <omgdi:waypoint x="1210.0002839785393" y="137.0891701657418"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="s11" id="BPMNEdge_s11">
        <omgdi:waypoint x="1296.1333618164062" y="287.0"/>
        <omgdi:waypoint x="1341.1333618164062" y="287.0"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
</code>
The InterruptHandler is a service task implementing ActivitiBehavior interface. When the cancel request comes, it sets the variableFlag for ExlusiveGateway and forces completion of the user task. This changes the path of execution in order to reach the CancelEndEvent. The WaitState user task have been added to get some additional flow control. Timer must have been used because the WaitState user task was completing "too slow", locking the DB and breaking the cancel with DB constraint anyway. It was working pretty fine without Compensation enabled.

Unfortunately for unknown reasons this workaround stops working when I set the isForCompensation flag to true on the compensation tasks. It breaks the same way as my process described in the first post and provided unit test (DB constraint violation exception). Seems like the timer stays in the database for what I've seen…

I thought it can mean something to You.

Best regards,
Vanquis