Camunda Workflow gets restarted after 5 mins if we use timer/ Thread sleep

Objective - I want to add a task which should be executed after 5min and again wait for next loop.
Problem: After 5 mints, whole Workflow gets restarted without any exception/ error.

Sample WF which has restart issue-

<?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: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_1r031eu" 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_10818qo" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" name="Start">
      <bpmn:outgoing>Flow_10oegyg</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:scriptTask id="Activity_0my8znr" name="task a" scriptFormat="groovy">
      <bpmn:incoming>Flow_10oegyg</bpmn:incoming>
      <bpmn:outgoing>Flow_19vdrz3</bpmn:outgoing>
      <bpmn:script> execution.setVariable("taskList", 5)  </bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="Flow_10oegyg" sourceRef="StartEvent_1" targetRef="Activity_0my8znr" />
    <bpmn:scriptTask id="Activity_1pco3ch" name="task b" scriptFormat="groovy">
      <bpmn:incoming>Flow_19vdrz3</bpmn:incoming>
      <bpmn:incoming>Flow_1uc3po0</bpmn:incoming>
      <bpmn:outgoing>Flow_0c0udak</bpmn:outgoing>
      <bpmn:script> int taskList =   execution.getVariable("taskList") ;
taskList = taskList +1
execution.setVariable("taskList", taskList)</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="Flow_19vdrz3" sourceRef="Activity_0my8znr" targetRef="Activity_1pco3ch" />
    <bpmn:scriptTask id="Activity_1jgar9y" name="task c" scriptFormat="groovy">
      <bpmn:incoming>Flow_0c0udak</bpmn:incoming>
      <bpmn:incoming>Flow_1wnn8tc</bpmn:incoming>
      <bpmn:outgoing>Flow_1pj8u6u</bpmn:outgoing>
      <bpmn:script> int poll = execution.getVariable("poll") != null ? execution.getVariable("poll") : 0;

poll = poll +1
execution.setVariable("poll", poll)</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:sequenceFlow id="Flow_0c0udak" sourceRef="Activity_1pco3ch" targetRef="Activity_1jgar9y" />
    <bpmn:exclusiveGateway id="Gateway_0bmnzz8">
      <bpmn:incoming>Flow_1pj8u6u</bpmn:incoming>
      <bpmn:outgoing>Flow_0kj0cke</bpmn:outgoing>
      <bpmn:outgoing>Flow_1uc3po0</bpmn:outgoing>
      <bpmn:outgoing>Flow_0aoez07</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:sequenceFlow id="Flow_0kj0cke" sourceRef="Gateway_0bmnzz8" targetRef="Event_1g5z2ku">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${poll &lt; 6 &amp;&amp;  taskList != 0 }</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_1wnn8tc" sourceRef="Event_1g5z2ku" targetRef="Activity_1jgar9y" />
    <bpmn:intermediateCatchEvent id="Event_1g5z2ku">
      <bpmn:incoming>Flow_0kj0cke</bpmn:incoming>
      <bpmn:outgoing>Flow_1wnn8tc</bpmn:outgoing>
      <bpmn:timerEventDefinition id="TimerEventDefinition_0wc1xh3">
        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT6M</bpmn:timeDuration>
      </bpmn:timerEventDefinition>
    </bpmn:intermediateCatchEvent>
    <bpmn:sequenceFlow id="Flow_1pj8u6u" sourceRef="Activity_1jgar9y" targetRef="Gateway_0bmnzz8" />
    <bpmn:sequenceFlow id="Flow_1uc3po0" sourceRef="Gateway_0bmnzz8" targetRef="Activity_1pco3ch">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${poll  &gt; 5 &amp;&amp;  taskList != 0 }</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:endEvent id="Event_089ivuk">
      <bpmn:incoming>Flow_0aoez07</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0aoez07" sourceRef="Gateway_0bmnzz8" targetRef="Event_089ivuk">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${   taskList == 0 }</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_10818qo">
      <bpmndi:BPMNEdge id="Flow_10oegyg_di" bpmnElement="Flow_10oegyg">
        <di:waypoint x="178" y="117" />
        <di:waypoint x="230" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_19vdrz3_di" bpmnElement="Flow_19vdrz3">
        <di:waypoint x="330" y="117" />
        <di:waypoint x="430" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0c0udak_di" bpmnElement="Flow_0c0udak">
        <di:waypoint x="480" y="157" />
        <di:waypoint x="480" y="184" />
        <di:waypoint x="520" y="184" />
        <di:waypoint x="520" y="210" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0kj0cke_di" bpmnElement="Flow_0kj0cke">
        <di:waypoint x="545" y="370" />
        <di:waypoint x="622" y="370" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1wnn8tc_di" bpmnElement="Flow_1wnn8tc">
        <di:waypoint x="640" y="352" />
        <di:waypoint x="640" y="250" />
        <di:waypoint x="570" y="250" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1pj8u6u_di" bpmnElement="Flow_1pj8u6u">
        <di:waypoint x="520" y="290" />
        <di:waypoint x="520" y="345" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1uc3po0_di" bpmnElement="Flow_1uc3po0">
        <di:waypoint x="495" y="370" />
        <di:waypoint x="360" y="370" />
        <di:waypoint x="360" y="150" />
        <di:waypoint x="430" y="150" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0aoez07_di" bpmnElement="Flow_0aoez07">
        <di:waypoint x="520" y="395" />
        <di:waypoint x="520" y="482" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="BPMNShape_0ksn4sw" bpmnElement="Activity_1jgar9y">
        <dc:Bounds x="470" y="210" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0bmnzz8_di" bpmnElement="Gateway_0bmnzz8" isMarkerVisible="true">
        <dc:Bounds x="495" y="345" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1a85yy8_di" bpmnElement="Event_1g5z2ku">
        <dc:Bounds x="622" y="352" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="142" y="99" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="148" y="142" width="24" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_15rd2c3_di" bpmnElement="Activity_0my8znr">
        <dc:Bounds x="230" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_1vtjvka" bpmnElement="Activity_1pco3ch">
        <dc:Bounds x="430" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_089ivuk_di" bpmnElement="Event_089ivuk">
        <dc:Bounds x="502" y="482" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Note: Sample WF has sample script just for showing how WF gets restarted from start point

Can you upload the bpmn model that you’ve created so far, it’ll help understand what you’ve already tried.

added sample pic

I notice that the task in your model has no task type.
This would mean the engine would always just pass through it, so it may seems like it never actually executes.

Added sample WF.
Dont observe logic, just check how it is getting restarted after 5 min without error

Thanks for quick reply

please check it

Nothing is clear from the model your send.
Giving more accurate information about your problem would help, including defining in more detail exactly what is happening.

problem- when we start this workflow following flow happens -

  1. Start workflow from Start event
  2. Task/ script A gets executed
  3. Task/ script B gets executed (It increases taskList by 1 )
  4. Task/ Script C gets executed ( it sets poll counter )
  5. Gateway checks it should end or execute timer or execute Task/ script B
  6. if poll < 6 && taskList != 0 then timer gets executes
  7. timer waits for 5 min
  8. task/ script C gets executed after 5 min

and so on …
Expectation - Task/ script B should get executed 5 times and for every execution Task C should poll 6 times with each 5 min wait ( timer is set for 5min)

Then End .

Problem -
We observed that in above flow WHOLE workflow gets restarts again from Task/ Script A

Note: This is just example WF to demonstrate how timer ( 5min ) create problem which causes workflow restart
Take updated WF from question

Can you clearly define what you mean by restart?
The process instance starts again?

Process instance starts again .
It restarts from staring point ( from Async task/ activity ), if log is added in Task/ script A, you can see log again and again.
In example case , it is starting point.