Duplicate jobs created when exiting called subprocess

I am using Camunda 7.13 (embedded engine + spring boot) and encountered a strange behavior:
A process runs ok until the call to a subprocess via Call activity. Inside, some data is retrieved using a rest call, then a condition is checked based on that data and when the condition is false, it exits the subprocess via End event. When it exits, the execution from the original process is duplicated (by suspending the process after a step, I can see two jobs that are exactly the same), so every step after this one is performed twice.
For some reason, this only happens within this process, even though there are others that call subprocesses in the same way.
I have provided the bpmn files (with changed names of classes and steps, but exactly the same configuration)

Process 1:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1b6q5ii" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0">
  <bpmn:process id="process_1" name="Porocess with issue" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_1rsn9go</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:exclusiveGateway id="Gateway_07ggcx0" default="Flow_0dakg7l">
      <bpmn:incoming>Flow_1jiiwfs</bpmn:incoming>
      <bpmn:outgoing>Flow_0xj59sz</bpmn:outgoing>
      <bpmn:outgoing>Flow_0dakg7l</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:callActivity id="Activity_1or79yp" name="Call other subprocess" camunda:asyncBefore="true" camunda:asyncAfter="true" calledElement="process_3">
      <bpmn:extensionElements>
        <camunda:in businessKey="#{execution.processBusinessKey}" />
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0deu1wd</bpmn:incoming>
      <bpmn:incoming>Flow_07bl8ys</bpmn:incoming>
      <bpmn:outgoing>Flow_1v5j1z3</bpmn:outgoing>
    </bpmn:callActivity>
    <bpmn:callActivity id="Activity_1i4apee" name="Call subprocess" camunda:asyncBefore="true" camunda:asyncAfter="true" calledElement="process_2">
      <bpmn:extensionElements>
        <camunda:in businessKey="#{execution.processBusinessKey}" />
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0xj59sz</bpmn:incoming>
      <bpmn:outgoing>Flow_0deu1wd</bpmn:outgoing>
      <bpmn:outgoing>Flow_07bl8ys</bpmn:outgoing>
    </bpmn:callActivity>
    <bpmn:sequenceFlow id="Flow_0xj59sz" sourceRef="Gateway_07ggcx0" targetRef="Activity_1i4apee" />
    <bpmn:sequenceFlow id="Flow_0deu1wd" sourceRef="Activity_1i4apee" targetRef="Activity_1or79yp" />
    <bpmn:sequenceFlow id="Flow_07bl8ys" sourceRef="Activity_1i4apee" targetRef="Activity_1or79yp" />
    <bpmn:serviceTask id="Activity_1gawolh" name="Check condition" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:class="com.example.CheckClass">
      <bpmn:incoming>Flow_1rsn9go</bpmn:incoming>
      <bpmn:outgoing>Flow_1jiiwfs</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_1rsn9go" sourceRef="StartEvent_1" targetRef="Activity_1gawolh" />
    <bpmn:sequenceFlow id="Flow_1jiiwfs" sourceRef="Activity_1gawolh" targetRef="Gateway_07ggcx0" />
    <bpmn:endEvent id="Event_0l9om8o">
      <bpmn:incoming>Flow_0dakg7l</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0dakg7l" sourceRef="Gateway_07ggcx0" targetRef="Event_0l9om8o" />
    <bpmn:endEvent id="Event_0cir99m">
      <bpmn:incoming>Flow_1v5j1z3</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1v5j1z3" sourceRef="Activity_1or79yp" targetRef="Event_0cir99m" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="process_1">
      <bpmndi:BPMNEdge id="Flow_0xj59sz_di" bpmnElement="Flow_0xj59sz">
        <di:waypoint x="455" y="117" />
        <di:waypoint x="500" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0deu1wd_di" bpmnElement="Flow_0deu1wd">
        <di:waypoint x="600" y="117" />
        <di:waypoint x="630" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_07bl8ys_di" bpmnElement="Flow_07bl8ys">
        <di:waypoint x="600" y="117" />
        <di:waypoint x="630" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1rsn9go_di" bpmnElement="Flow_1rsn9go">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="260" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1jiiwfs_di" bpmnElement="Flow_1jiiwfs">
        <di:waypoint x="360" y="117" />
        <di:waypoint x="405" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0dakg7l_di" bpmnElement="Flow_0dakg7l">
        <di:waypoint x="430" y="142" />
        <di:waypoint x="430" y="212" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1v5j1z3_di" bpmnElement="Flow_1v5j1z3">
        <di:waypoint x="730" y="117" />
        <di:waypoint x="762" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1gawolh_di" bpmnElement="Activity_1gawolh">
        <dc:Bounds x="260" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_07ggcx0_di" bpmnElement="Gateway_07ggcx0" isMarkerVisible="true">
        <dc:Bounds x="405" y="92" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0l9om8o_di" bpmnElement="Event_0l9om8o">
        <dc:Bounds x="412" y="212" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1or79yp_di" bpmnElement="Activity_1or79yp">
        <dc:Bounds x="630" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1i4apee_di" bpmnElement="Activity_1i4apee">
        <dc:Bounds x="500" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0cir99m_di" bpmnElement="Event_0cir99m">
        <dc:Bounds x="762" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Process 2:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_10apips" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0">
  <bpmn:process id="process_2" name="Subprocess" isExecutable="true">
    <bpmn:serviceTask id="Activity_0hdnpm2" name="Get latest details" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:class="com.example.GetDataClass">
      <bpmn:incoming>Flow_1xyiy9d</bpmn:incoming>
      <bpmn:outgoing>Flow_0x8nrng</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="Activity_0nsgqhj" name="Perform action" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:class="com.example.ActionClass">
      <bpmn:incoming>Flow_1jly1tl</bpmn:incoming>
      <bpmn:outgoing>Flow_0gz6rf9</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="Activity_1gawolh" name="Check condition" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:class="com.example.CheckClass">
      <bpmn:incoming>Flow_0x8nrng</bpmn:incoming>
      <bpmn:outgoing>Flow_0ivl1o1</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:exclusiveGateway id="Gateway_10bialn" default="Flow_1adrjji">
      <bpmn:incoming>Flow_0ivl1o1</bpmn:incoming>
      <bpmn:outgoing>Flow_1jly1tl</bpmn:outgoing>
      <bpmn:outgoing>Flow_1adrjji</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:endEvent id="Event_1keim72">
      <bpmn:incoming>Flow_1adrjji</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:startEvent id="Event_0fydvhf">
      <bpmn:outgoing>Flow_1xyiy9d</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_1xyiy9d" sourceRef="Event_0fydvhf" targetRef="Activity_0hdnpm2" />
    <bpmn:sequenceFlow id="Flow_0x8nrng" sourceRef="Activity_0hdnpm2" targetRef="Activity_1gawolh" />
    <bpmn:sequenceFlow id="Flow_1jly1tl" name="Condition ok" sourceRef="Gateway_10bialn" targetRef="Activity_0nsgqhj">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${checkOk}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_0ivl1o1" sourceRef="Activity_1gawolh" targetRef="Gateway_10bialn" />
    <bpmn:sequenceFlow id="Flow_1adrjji" sourceRef="Gateway_10bialn" targetRef="Event_1keim72" />
    <bpmn:endEvent id="Event_1uueb3v">
      <bpmn:incoming>Flow_0gz6rf9</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0gz6rf9" sourceRef="Activity_0nsgqhj" targetRef="Event_1uueb3v" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="process_2">
      <bpmndi:BPMNEdge id="Flow_0gz6rf9_di" bpmnElement="Flow_0gz6rf9">
        <di:waypoint x="770" y="117" />
        <di:waypoint x="832" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1adrjji_di" bpmnElement="Flow_1adrjji">
        <di:waypoint x="560" y="142" />
        <di:waypoint x="560" y="212" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0ivl1o1_di" bpmnElement="Flow_0ivl1o1">
        <di:waypoint x="490" y="117" />
        <di:waypoint x="535" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1jly1tl_di" bpmnElement="Flow_1jly1tl">
        <di:waypoint x="585" y="117" />
        <di:waypoint x="670" y="117" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="599" y="99" width="62" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0x8nrng_di" bpmnElement="Flow_0x8nrng">
        <di:waypoint x="350" y="117" />
        <di:waypoint x="390" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1xyiy9d_di" bpmnElement="Flow_1xyiy9d">
        <di:waypoint x="188" y="117" />
        <di:waypoint x="250" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="Activity_0hdnpm2_di" bpmnElement="Activity_0hdnpm2">
        <dc:Bounds x="250" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0nsgqhj_di" bpmnElement="Activity_0nsgqhj">
        <dc:Bounds x="670" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1gawolh_di" bpmnElement="Activity_1gawolh">
        <dc:Bounds x="390" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_10bialn_di" bpmnElement="Gateway_10bialn" isMarkerVisible="true">
        <dc:Bounds x="535" y="92" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1keim72_di" bpmnElement="Event_1keim72">
        <dc:Bounds x="542" y="212" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0fydvhf_di" bpmnElement="Event_0fydvhf">
        <dc:Bounds x="152" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1uueb3v_di" bpmnElement="Event_1uueb3v">
        <dc:Bounds x="832" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Hi @Cody_Newman

Welcome along to the forum.
It looks like you have two overlapping sequence flows leaving your call activity, which would produce two tokens. Deleting one of them should solve the problem.

duplicateSeqCall

2 Likes

Thanks for the incredibly fast response! Yes, indeed, I now see the second sequence flow.

1 Like