flowable / flowable-engine

A compact and highly efficient workflow and Business Process Management (BPM) platform for developers, system admins and business users.
https://www.flowable.org
Apache License 2.0
7.95k stars 2.62k forks source link

Flow does not continue after FlowableOptimisticLockingException #2124

Open abarazal opened 4 years ago

abarazal commented 4 years ago

Describe the bug 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.

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?

Expected behavior 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.

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: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>

Additional context Flowable version: 6.4.2 Database vendor: Oracle We are using Flowable with Spring Boot

tijsrademakers commented 4 years ago

Hi,

The simpleLog async service task is set to exclusive = false, which means that they can be executed at the same time by the async executor. When this happens they will at the same time try to update the parent multi instance execution and that's why the optimistic locking exception is thrown. When you change exclusive to true this is not expected to happen.

filiphr commented 4 years ago

Reopening since we would like to have an ability like the Parallel gateway async join. This new feature would make sure that multi instance activities can run not exclusively in parallel and thus avoiding a FlowableOptimisticLockingException

kyelaman commented 1 year ago

@tijsrademakers @filiphr Any update on the above open issue? We have a different use case, albeit with the same issue where we want to be able to run in parallel with multi instance activities and not be able to run exclusively.