camunda / camunda-bpm-platform

Flexible framework for workflow and decision automation with BPMN and DMN. Integration with Quarkus, Spring, Spring Boot, CDI.
https://camunda.com/
Apache License 2.0
4.12k stars 1.56k forks source link

Incorrect process instance count in Cockpit process definition statistics query #4756

Open mboskamp opened 4 days ago

mboskamp commented 4 days ago

Environment (Required on creation)

Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket)

When multiple instances of a process definition are running with at least two open incidents for each instance of different incident types, the count of running process instances in the Processes view in Cockpit is wrong. The displayed count is equal to the actual count times the amount of different incident types. For example: There are two incidents with different types per instance and three instances are running. The Processes view in Cockpit would display six running instances (3 instances x 2 incident types).

Steps to reproduce (Required on creation)

  1. Start Camunda Platform and an External Taks client listening for tasks with topic parallel.
  2. Deploy the folowing process definition. The process has a parallel gateway with flows to a service task and an external task. Both tasks will produce an incident.
    Details

<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.28.0">
  <bpmn:process id="SUPPORT-24279" name="SUPPORT-24279" isExecutable="true" camunda:historyTimeToLive="P180D">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_15jvgxo</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:parallelGateway id="Gateway_0gkcdbn" camunda:asyncBefore="true">
      <bpmn:incoming>Flow_15jvgxo</bpmn:incoming>
      <bpmn:outgoing>Flow_08pmtzv</bpmn:outgoing>
      <bpmn:outgoing>Flow_1srcsc9</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:endEvent id="Event_1fgvzc7">
      <bpmn:incoming>Flow_0k8u6y2</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:serviceTask id="Activity_1vavuav" name="Ext" camunda:asyncBefore="true" camunda:type="external" camunda:topic="parallel">
      <bpmn:incoming>Flow_08pmtzv</bpmn:incoming>
      <bpmn:outgoing>Flow_1a010v7</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="Activity_0zedjyo" name="Deleg" camunda:asyncBefore="true" camunda:delegateExpression="${logger}">
      <bpmn:incoming>Flow_1srcsc9</bpmn:incoming>
      <bpmn:outgoing>Flow_0h86lip</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:parallelGateway id="Gateway_0muk4v7">
      <bpmn:incoming>Flow_1a010v7</bpmn:incoming>
      <bpmn:incoming>Flow_0h86lip</bpmn:incoming>
      <bpmn:outgoing>Flow_0k8u6y2</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:sequenceFlow id="Flow_15jvgxo" sourceRef="StartEvent_1" targetRef="Gateway_0gkcdbn" />
    <bpmn:sequenceFlow id="Flow_08pmtzv" sourceRef="Gateway_0gkcdbn" targetRef="Activity_1vavuav" />
    <bpmn:sequenceFlow id="Flow_1srcsc9" sourceRef="Gateway_0gkcdbn" targetRef="Activity_0zedjyo" />
    <bpmn:sequenceFlow id="Flow_1a010v7" sourceRef="Activity_1vavuav" targetRef="Gateway_0muk4v7" />
    <bpmn:sequenceFlow id="Flow_0h86lip" sourceRef="Activity_0zedjyo" targetRef="Gateway_0muk4v7" />
    <bpmn:sequenceFlow id="Flow_0k8u6y2" sourceRef="Gateway_0muk4v7" targetRef="Event_1fgvzc7" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="SUPPORT-24279">
      <bpmndi:BPMNShape id="BPMNShape_02gwq12" bpmnElement="StartEvent_1">
        <dc:Bounds x="162" y="192" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_1vs9n3z_di" bpmnElement="Gateway_0gkcdbn">
        <dc:Bounds x="255" y="185" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_15c8ouv_di" bpmnElement="Activity_1vavuav">
        <dc:Bounds x="370" y="80" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_02r1kdb_di" bpmnElement="Activity_0zedjyo">
        <dc:Bounds x="370" y="260" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_12s854q_di" bpmnElement="Gateway_0muk4v7">
        <dc:Bounds x="545" y="185" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1fgvzc7_di" bpmnElement="Event_1fgvzc7">
        <dc:Bounds x="692" y="192" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_15jvgxo_di" bpmnElement="Flow_15jvgxo">
        <di:waypoint x="198" y="210" />
        <di:waypoint x="255" y="210" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_08pmtzv_di" bpmnElement="Flow_08pmtzv">
        <di:waypoint x="280" y="185" />
        <di:waypoint x="280" y="120" />
        <di:waypoint x="370" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1srcsc9_di" bpmnElement="Flow_1srcsc9">
        <di:waypoint x="280" y="235" />
        <di:waypoint x="280" y="300" />
        <di:waypoint x="370" y="300" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1a010v7_di" bpmnElement="Flow_1a010v7">
        <di:waypoint x="470" y="120" />
        <di:waypoint x="570" y="120" />
        <di:waypoint x="570" y="185" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0h86lip_di" bpmnElement="Flow_0h86lip">
        <di:waypoint x="470" y="300" />
        <di:waypoint x="570" y="300" />
        <di:waypoint x="570" y="235" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0k8u6y2_di" bpmnElement="Flow_0k8u6y2">
        <di:waypoint x="595" y="210" />
        <di:waypoint x="692" y="210" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

  1. Start at least two instances of the process.
  2. You should see four incidents (two per running instance)
  3. Navigate to the Processes view in Cockpit: http://localhost:8080/camunda/app/cockpit/default/#/processes
  4. Observe the count of running process instances.

Observed Behavior (Required on creation)

The running process instances count is double what we would expect. For example: With two instances of the example process above, you should see a running instances count of four. However, only two instances are running.

Expected behavior (Required on creation)

The running instances count is correctly displayed. For example: With two instances of the example process above, you should see two running instances.

Root Cause (Required on prioritization)

The query used for the statistics is this one: https://github.com/camunda/camunda-bpm-platform/blob/ab78ff5959ba9ed94ea7538a789fe12c442ae3c1/webapps/assembly/src/main/resources/org/camunda/bpm/cockpit/plugin/base/queries/processDefinition.xml#L55

The query groups instances by incident type (here and here). This part of the query was initially copied from the statistics endpoint in the public API. This endpoint can filter and sort by incident type. The Cockpit variant does not need this functionality and does not support it.

Solution Ideas

Remove the grouping by INCIDENT_TYPE_ from the Cockpit query.

Hints

Links

Breakdown

### Pull Requests
- [ ] https://github.com/camunda/camunda-bpm-platform/pull/4752

Dev2QA handover

venetrius commented 1 day ago

Hi @mboskamp, @tasso94, Assigning this ticket to @tasso94 as per our Community Worker Process

mboskamp commented 1 day ago

This ticket was created on behalf of https://jira.camunda.com/browse/SUPPORT-24279. Right now, there is nothing to do here. Once we commit to a delivery timeline, it can be assigned to an engineer.

tasso94 commented 21 hours ago

Hey @mboskamp and @venetrius, next time, feel free to just remove the ticket from our project board. It's enough to maintain a reference from the support case. I'll take care of adding it back once we committed to a patch release.