Flow does not continue after flowable exception

Given the flow below, we experience a problem with concurrency when executing the “simpleLog” (async) service task in parallel with cardinality = 5, after which the flow does not continue with the “dummy” (exclusive) service task of the next step nor retry the job in “simpleLog”. Instead, we get 4 FlowableOptimisticLockingException.
To be detailed, “simpleLog” only prints some hardcoded string, sleeps 3 seconds (to simulate a real task) and shows another hardcoded string. “dummy” shows another text and “finalLog” shows all global variables.
What could be wrong here? Should flowable retry 3 times after FlowableOptimisticLockingException as we have read here: https://flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#fail-retry ? Why the flow does not continue?

We have tried to test if it works like commented here: How to get a single multi-instance task to execute in parallel?, but we had no success.

<?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:flowable="http://flowable.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.flowable.org/processdef">
  <process id="parallelServicetask" name="parallelServicetask" isExecutable="true">
    <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
    <serviceTask id="first" name="first" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.First"></serviceTask>
    <serviceTask id="finalLog" name="finalLog" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.Log"></serviceTask>
    <sequenceFlow id="sid-B08D33F0-4802-4AF7-AC57-826CCFC59F02" sourceRef="startEvent1" targetRef="first"></sequenceFlow>
    <endEvent id="sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC"></endEvent>
    <sequenceFlow id="sid-B2EDAC42-2DB8-4E99-B629-5FCBD0B8C9D4" sourceRef="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64" targetRef="finalLog"></sequenceFlow>
    <subProcess id="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64" name="subProcess">
      <serviceTask id="simpleLog" name="simpleLog" flowable:async="true" flowable:exclusive="false" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.LogThread">
        <multiInstanceLoopCharacteristics isSequential="false">
          <loopCardinality>5</loopCardinality>
        </multiInstanceLoopCharacteristics>
      </serviceTask>
      <serviceTask id="dummy" name="dummy" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.Dummy"></serviceTask>
      <startEvent id="sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3" flowable:formFieldValidation="true"></startEvent>
      <endEvent id="sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9"></endEvent>
      <sequenceFlow id="sid-86F155DC-5098-4803-A774-2E0E519671E0" sourceRef="dummy" targetRef="sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9"></sequenceFlow>
      <sequenceFlow id="sid-0E862BB9-F8B5-4C4D-9DF8-EFDAC049FB51" sourceRef="sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3" targetRef="simpleLog"></sequenceFlow>
      <sequenceFlow id="sid-5B2902A3-8F34-4044-8760-2586187F50AF" sourceRef="simpleLog" targetRef="dummy"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="sid-5FE1F875-3C70-4C44-9593-013C0CF96C82" sourceRef="finalLog" targetRef="sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC"></sequenceFlow>
    <sequenceFlow id="sid-F442D23D-60F5-419F-8131-AB1E780BE326" sourceRef="first" targetRef="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_parallelServicetask">
    <bpmndi:BPMNPlane bpmnElement="parallelServicetask" id="BPMNPlane_parallelServicetask">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="29.99999999999997" width="30.000000000000007" x="63.225147766400106" y="254.02632989760096"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="first" id="BPMNShape_first">
        <omgdc:Bounds height="80.0" width="100.0" x="28.225147766400113" y="420.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="finalLog" id="BPMNShape_finalLog">
        <omgdc:Bounds height="80.0" width="100.0" x="1044.330467356804" y="420.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC" id="BPMNShape_sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC">
        <omgdc:Bounds height="28.0" width="28.0" x="1080.330467356804" y="620.9532508608023"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64" id="BPMNShape_sid-5819B32A-B13B-49D8-97A6-D409A81AFB64">
        <omgdc:Bounds height="396.6088081391821" width="756.9219009007616" x="214.41134932956686" y="260.7706994757856"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="simpleLog" id="BPMNShape_simpleLog">
        <omgdc:Bounds height="80.0" width="100.00000000000006" x="420.0" y="420.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="dummy" id="BPMNShape_dummy">
        <omgdc:Bounds height="80.0" width="100.0" x="660.0" y="420.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3" id="BPMNShape_sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3">
        <omgdc:Bounds height="30.0" width="30.0" x="257.9999999999999" y="444.07510354537663"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9" id="BPMNShape_sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9">
        <omgdc:Bounds height="28.0" width="28.0" x="909.9999999999999" y="446.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-86F155DC-5098-4803-A774-2E0E519671E0" id="BPMNEdge_sid-86F155DC-5098-4803-A774-2E0E519671E0">
        <omgdi:waypoint x="759.9499999999999" y="460.01594128181614"></omgdi:waypoint>
        <omgdi:waypoint x="909.9999999999999" y="460.01594128181614"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-B08D33F0-4802-4AF7-AC57-826CCFC59F02" id="BPMNEdge_sid-B08D33F0-4802-4AF7-AC57-826CCFC59F02">
        <omgdi:waypoint x="78.22514776640011" y="283.97632939653414"></omgdi:waypoint>
        <omgdi:waypoint x="78.22514776640011" y="420.01594128181614"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-5B2902A3-8F34-4044-8760-2586187F50AF" id="BPMNEdge_sid-5B2902A3-8F34-4044-8760-2586187F50AF">
        <omgdi:waypoint x="519.95" y="460.003317779278"></omgdi:waypoint>
        <omgdi:waypoint x="660.0" y="460.0126201814378"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-F442D23D-60F5-419F-8131-AB1E780BE326" id="BPMNEdge_sid-F442D23D-60F5-419F-8131-AB1E780BE326">
        <omgdi:waypoint x="128.17514776635966" y="459.9245351861292"></omgdi:waypoint>
        <omgdi:waypoint x="214.4113493295555" y="459.76688489629385"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-0E862BB9-F8B5-4C4D-9DF8-EFDAC049FB51" id="BPMNEdge_sid-0E862BB9-F8B5-4C4D-9DF8-EFDAC049FB51">
        <omgdi:waypoint x="287.9498208930293" y="459.14529174490895"></omgdi:waypoint>
        <omgdi:waypoint x="419.99999999999966" y="459.7652547069484"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-5FE1F875-3C70-4C44-9593-013C0CF96C82" id="BPMNEdge_sid-5FE1F875-3C70-4C44-9593-013C0CF96C82">
        <omgdi:waypoint x="1094.330467356804" y="499.9659412818162"></omgdi:waypoint>
        <omgdi:waypoint x="1094.330467356804" y="620.9532508608023"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-B2EDAC42-2DB8-4E99-B629-5FCBD0B8C9D4" id="BPMNEdge_sid-B2EDAC42-2DB8-4E99-B629-5FCBD0B8C9D4">
        <omgdi:waypoint x="971.2832502303205" y="459.78507962131937"></omgdi:waypoint>
        <omgdi:waypoint x="1044.330467356804" y="459.922131090132"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Hey @abarazal,

I see that this is the same as this StackOverflow question.

For clarity I am copying the original answer from StackOverflow here as well.


Looking at the configuration simpleLog service task

<serviceTask id="simpleLog" name="simpleLog" flowable:async="true" flowable:exclusive="false" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.LogThread">
    <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>5</loopCardinality>
    </multiInstanceLoopCharacteristics>
</serviceTask>

It has flowable:exclusive="false" this means all (5) service tasks would be running in parallel. When their logic is done then all of them will continue and try to merge the multi instance. When the merging is happening all the threads will try to update the same entity. Only one of those will succeed and you will have 4 FlowableOptimisticLockingException (one would succeed).

After that the 4 will retry again leading to 3 throwing the exception, then the 3 will try again leading to 2 throwing the exception and ending up as deadlock jobs (I assume that this is what happens for you).

Currently the only way to circumvent this is to use flowable:exclusive="true" which is not truly parallel, since only one service task is then executed at any given time.

I would suggest that you open an issue in the Flowable issue tracker regarding this problem. There is a potential improvement that we can do in this case to be able your jobs to run truly in parallel, but then the merge of the activity to happen in a different async exclusive job.


We saw that you already created an issue (flowable/flowable-engine#2124) already as well, thanks