Camunda7 - Completing (springboot) a task when multiple active process instances available is failing

I’m exploring Camunda7 springboot version with simple BPM samples to build new capabilities

Scenario 1
I created a Camunda model and then created multiple process instances for that process. If there is only one process, task completes normally. But When there are multiple process instances active (each at same task as current task or each of them with different task as current task), I’m unable to complete the task.

Scenario 2:
I used different process definition versions (minor edits for version 1 and deployed as version 2)

  • I first started a process with Version 1 BPM definition and it has a task assigned to it. Task Def Key: ‘applicationTask’; Process Insatance Id: ‘8aebebc1-013b-11ef-8d61-de9417499372’

  • Later, I RESTARTED the server, started another instance for the same process with version 2 (updated BPM). This has another task assigned to it. Process Instance Id: ‘cae104a0-013a-11ef-b6f7-de9417499372’; Task Def Key: ‘approvalTask’

Its failing with an exception: The step taskService.complete(task.getId(), taskAttributes) fails with the following exception: org.camunda.bpm.engine.ProcessEngineException: Query return 3 results instead of max 1

I must be doing something fundamentally wrong but don’t know what. My earlier experience was with Apache Activity and Camunda is first time.

Java code:

public WorkflowMessage completeTask(final String processInstanceId, final String taskName, final Map<String, Object> taskAttributes) {
        final TaskService taskService = processEngine.getTaskService();
        final Task task = getTask(processInstanceId, taskName);
        logger.info("OK -> Found the task by Process instance id: {}. Task name is: {}; Task Attrbutes: {}", processInstanceId, taskName, taskAttributes);
        if (taskAttributes == null || taskAttributes.isEmpty()) {
            taskService.complete(task.getId());
        } else {
            taskService.complete(task.getId(), taskAttributes);
        }
        .....
    }

BPMN Model (Version 2)

<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_ll67ABGYEeW7xqkBzIjHqw" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="5.20.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
  <bpmn2:process id="simpleApplication" name="SimpleApplication" isExecutable="true" camunda:historyTimeToLive="P180D">
    <bpmn2:startEvent id="startEvent" name="Start">
      <bpmn2:outgoing>startEventEnd</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:userTask id="applicationTask" name="Application">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="Input_0squklg" />
          <camunda:outputParameter name="applicationType">${applicationType}</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>startEventEnd</bpmn2:incoming>
      <bpmn2:outgoing>enquiryEnd</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:sequenceFlow id="startEventEnd" sourceRef="startEvent" targetRef="applicationTask" />
    <bpmn2:sequenceFlow id="enquiryEnd" sourceRef="applicationTask" targetRef="applicationTypeGateway" />
    <bpmn2:endEvent id="endEvent" name="Approved">
      <bpmn2:incoming>approvalEnd</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:sequenceFlow id="applicationGatewayEnd" sourceRef="applicationTypeGateway" targetRef="accountApplicationTask">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${applicationType == 'Account'}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:exclusiveGateway id="applicationTypeGateway" name="Application Type">
      <bpmn2:incoming>enquiryEnd</bpmn2:incoming>
      <bpmn2:outgoing>applicationGatewayEnd</bpmn2:outgoing>
      <bpmn2:outgoing>loanGatewayEnd</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:sequenceFlow id="loanGatewayEnd" sourceRef="applicationTypeGateway" targetRef="loanApplicationTask">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${applicationType == 'Loan'} </bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="loanApplicationEnd" sourceRef="loanApplicationTask" targetRef="mergingGateway" />
    <bpmn2:serviceTask id="loanApplicationTask" name="Loan Application" camunda:class="com.example.camunda.bpmn.delegate.LoanProcessingDelegate">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="applicationType">${applicationType}</camunda:inputParameter>
          <camunda:outputParameter name="applicationType">${applicationType}</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>loanGatewayEnd</bpmn2:incoming>
      <bpmn2:outgoing>loanApplicationEnd</bpmn2:outgoing>
    </bpmn2:serviceTask>
    <bpmn2:serviceTask id="accountApplicationTask" name="Account Application" camunda:class="com.example.camunda.bpmn.delegate.AccountProcessingDelegate">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="applicationType">${applicationType}</camunda:inputParameter>
          <camunda:outputParameter name="applicationType">${applicationType}</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>applicationGatewayEnd</bpmn2:incoming>
      <bpmn2:outgoing>accountApplicationEnd</bpmn2:outgoing>
    </bpmn2:serviceTask>
    <bpmn2:userTask id="approvalTask" name="Final Approval">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="applicationType">${applicationType}</camunda:inputParameter>
          <camunda:outputParameter name="approvalStatus">Approved</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>Flow_0va3h5o</bpmn2:incoming>
      <bpmn2:outgoing>approvalEnd</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:sequenceFlow id="approvalEnd" sourceRef="approvalTask" targetRef="endEvent" />
    <bpmn2:exclusiveGateway id="mergingGateway">
      <bpmn2:incoming>accountApplicationEnd</bpmn2:incoming>
      <bpmn2:incoming>loanApplicationEnd</bpmn2:incoming>
      <bpmn2:outgoing>Flow_0va3h5o</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:sequenceFlow id="accountApplicationEnd" sourceRef="accountApplicationTask" targetRef="mergingGateway" />
    <bpmn2:sequenceFlow id="Flow_0va3h5o" sourceRef="mergingGateway" targetRef="approvalTask" />
  </bpmn2:process>
</bpmn2:definitions>

SQL Query that’s causing the duplicate records

select distinct RES.REV_, RES.ID_, RES.NAME_, RES.PARENT_TASK_ID_, RES.DESCRIPTION_, RES.PRIORITY_, RES.CREATE_TIME_, RES.OWNER_, RES.ASSIGNEE_, RES.DELEGATION_, RES.EXECUTION_ID_, RES.PROC_INST_ID_, RES.PROC_DEF_ID_, RES.CASE_EXECUTION_ID_, RES.CASE_INST_ID_, RES.CASE_DEF_ID_, RES.TASK_DEF_KEY_, RES.DUE_DATE_, RES.FOLLOW_UP_DATE_, RES.SUSPENSION_STATE_, RES.TENANT_ID_, RES.LAST_UPDATED_ from ACT_RU_TASK RES WHERE ( 1 = 1 and RES.SUSPENSION_STATE_ = 1 ) order by RES.ID_ asc LIMIT ? OFFSET ?

Data in act_ru_table table:

"id_","rev_","execution_id_","proc_inst_id_","proc_def_id_","case_execution_id_","case_inst_id_","case_def_id_","name_","parent_task_id_","description_","task_def_key_","owner_","assignee_","delegation_","priority_","create_time_","last_updated_","due_date_","follow_up_date_","suspension_state_","tenant_id_"
"8aeed1f7-013b-11ef-8d61-de9417499372",1,"8aed7263-013b-11ef-8d61-de9417499372","8aebebc1-013b-11ef-8d61-de9417499372","simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372",NULL,NULL,NULL,"Application",NULL,NULL,"applicationTask",NULL,NULL,NULL,50,"2024-04-23 12:04:31.738",NULL,NULL,NULL,1,NULL
"fdc32436-013a-11ef-b6f7-de9417499372",1,"fdc32432-013a-11ef-b6f7-de9417499372","cae104a0-013a-11ef-b6f7-de9417499372","simpleApplication:1:e31d0c3f-0139-11ef-b6f7-de9417499372",NULL,NULL,NULL,"Final Approval",NULL,NULL,"approvalTask",NULL,NULL,NULL,50,"2024-04-23 12:00:34.893",NULL,NULL,NULL,1,NULL

My Log

12:04:31.777 [http-nio-8080-exec-2] INFO  c.e.c.s.impl.WorkflowServiceImpl - OK. Started with the task: Task Name: Application. Task id: 8aeed1f7-013b-11ef-8d61-de9417499372
12:04:31.782 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.m.a.HttpEntityMethodProcessor - Using 'application/json', given [*/*] and supported [application/json]
12:04:31.788 [http-nio-8080-exec-2] TRACE o.s.w.s.m.m.a.HttpEntityMethodProcessor - Writing [com.example.camunda.model.WorkflowMessage@19aca433]
12:04:31.794 [http-nio-8080-exec-2] TRACE o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Applying default cacheSeconds=-1
12:04:31.794 [http-nio-8080-exec-2] TRACE o.s.web.servlet.DispatcherServlet - No view rendering, null ModelAndView returned.
12:04:31.794 [http-nio-8080-exec-2] DEBUG o.s.web.servlet.DispatcherServlet - Completed 200 OK, headers={masked}
.....
o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to com.example.camunda.controller.WorkflowController#completeTask(Request)
....
12:04:37.625 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Acquired Connection [HikariProxyConnection@287496586 wrapping org.postgresql.jdbc.PgConnection@ce2eaa7] for JDBC transaction
12:04:37.625 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Switching JDBC Connection [HikariProxyConnection@287496586 wrapping org.postgresql.jdbc.PgConnection@ce2eaa7] to manual commit
12:04:37.643 [http-nio-8080-exec-3] DEBUG o.a.i.t.managed.ManagedTransaction - Opening JDBC Connection
12:04:37.643 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - ==>  Preparing: select distinct RES.REV_, RES.ID_, RES.NAME_, RES.PARENT_TASK_ID_, RES.DESCRIPTION_, RES.PRIORITY_, RES.CREATE_TIME_, RES.OWNER_, RES.ASSIGNEE_, RES.DELEGATION_, RES.EXECUTION_ID_, RES.PROC_INST_ID_, RES.PROC_DEF_ID_, RES.CASE_EXECUTION_ID_, RES.CASE_INST_ID_, RES.CASE_DEF_ID_, RES.TASK_DEF_KEY_, RES.DUE_DATE_, RES.FOLLOW_UP_DATE_, RES.SUSPENSION_STATE_, RES.TENANT_ID_, RES.LAST_UPDATED_ from ACT_RU_TASK RES WHERE ( 1 = 1 and UPPER(RES.NAME_) = UPPER(?) and RES.PROC_INST_ID_ = ? and RES.SUSPENSION_STATE_ = 1 ) order by RES.ID_ asc LIMIT ? OFFSET ?
12:04:37.644 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - ==> Parameters: Application(String), 8aebebc1-013b-11ef-8d61-de9417499372(String), 2147483647(Integer), 0(Integer)
12:04:37.645 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - <==    Columns: rev_, id_, name_, parent_task_id_, description_, priority_, create_time_, owner_, assignee_, delegation_, execution_id_, proc_inst_id_, proc_def_id_, case_execution_id_, case_inst_id_, case_def_id_, task_def_key_, due_date_, follow_up_date_, suspension_state_, tenant_id_, last_updated_
12:04:37.645 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - <==        Row: 1, 8aeed1f7-013b-11ef-8d61-de9417499372, Application, null, null, 50, 2024-04-23 12:04:31.738, null, null, null, 8aed7263-013b-11ef-8d61-de9417499372, 8aebebc1-013b-11ef-8d61-de9417499372, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, applicationTask, null, null, 1, null, null
12:04:37.646 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - <==      Total: 1
12:04:37.646 [http-nio-8080-exec-3] DEBUG org.camunda.bpm.engine.persistence - ENGINE-03006 Cache state after flush: [
  PERSISTENT TaskEntity[8aeed1f7-013b-11ef-8d61-de9417499372]
]
12:04:37.646 [http-nio-8080-exec-3] DEBUG o.a.i.t.managed.ManagedTransaction - Closing JDBC Connection [Transaction-aware proxy for target Connection [HikariProxyConnection@287496586 wrapping org.postgresql.jdbc.PgConnection@ce2eaa7]]
12:04:37.646 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Initiating transaction commit
12:04:37.646 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Committing JDBC transaction on Connection [HikariProxyConnection@287496586 wrapping org.postgresql.jdbc.PgConnection@ce2eaa7]
12:04:37.646 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Releasing JDBC Connection [HikariProxyConnection@287496586 wrapping org.postgresql.jdbc.PgConnection@ce2eaa7] after transaction
12:04:37.646 [http-nio-8080-exec-3] INFO  c.e.c.s.impl.WorkflowServiceImpl - Found total Application tasks matching Task name 8aebebc1-013b-11ef-8d61-de9417499372 under Process instance id: {}
12:04:37.648 [http-nio-8080-exec-3] INFO  c.e.c.s.impl.WorkflowServiceImpl - [Task[8aeed1f7-013b-11ef-8d61-de9417499372]]
12:04:37.648 [http-nio-8080-exec-3] INFO  c.e.c.s.impl.WorkflowServiceImpl - Task Id 8aeed1f7-013b-11ef-8d61-de9417499372 & Task Name: Application
12:04:37.648 [http-nio-8080-exec-3] INFO  c.e.c.s.impl.WorkflowServiceImpl - OK -> Found the task by Process instance id: 8aebebc1-013b-11ef-8d61-de9417499372. Task name is: Application; Task Attrbutes: {applicationType=Loan}
12:04:37.649 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
12:04:37.649 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Acquired Connection [HikariProxyConnection@1134896129 wrapping org.postgresql.jdbc.PgConnection@ce2eaa7] for JDBC transaction
12:04:37.649 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Switching JDBC Connection [HikariProxyConnection@1134896129 wrapping org.postgresql.jdbc.PgConnection@ce2eaa7] to manual commit
12:04:37.649 [http-nio-8080-exec-3] DEBUG o.a.i.t.managed.ManagedTransaction - Opening JDBC Connection
12:04:37.649 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.TaskEntity.selectTask - ==>  Preparing: select * from ACT_RU_TASK where ID_ = ?
12:04:37.649 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.TaskEntity.selectTask - ==> Parameters: 8aeed1f7-013b-11ef-8d61-de9417499372(String)
12:04:37.650 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.TaskEntity.selectTask - <==    Columns: id_, rev_, execution_id_, proc_inst_id_, proc_def_id_, case_execution_id_, case_inst_id_, case_def_id_, name_, parent_task_id_, description_, task_def_key_, owner_, assignee_, delegation_, priority_, create_time_, last_updated_, due_date_, follow_up_date_, suspension_state_, tenant_id_
12:04:37.650 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.TaskEntity.selectTask - <==        Row: 8aeed1f7-013b-11ef-8d61-de9417499372, 1, 8aed7263-013b-11ef-8d61-de9417499372, 8aebebc1-013b-11ef-8d61-de9417499372, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, Application, null, null, applicationTask, null, null, null, 50, 2024-04-23 12:04:31.738, null, null, null, 1, null
12:04:37.651 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.TaskEntity.selectTask - <==      Total: 1
12:04:37.651 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.P.selectProcessDefinition - ==>  Preparing: select * from ACT_RE_PROCDEF where ID_ = ?
12:04:37.651 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.P.selectProcessDefinition - ==> Parameters: simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372(String)
12:04:37.651 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.P.selectProcessDefinition - <==    Columns: id_, rev_, category_, name_, key_, version_, deployment_id_, resource_name_, dgrm_resource_name_, has_start_form_key_, suspension_state_, tenant_id_, version_tag_, history_ttl_, startable_
12:04:37.651 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.P.selectProcessDefinition - <==        Row: simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, 1, http://camunda.org/schema/1.0/bpmn, SimpleApplication, simpleApplication, 2, 6b26121e-013b-11ef-8d61-de9417499372, bpmn-sample.bpmn, null, f, 1, null, null, 180, t
12:04:37.652 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.P.selectProcessDefinition - <==      Total: 1
12:04:37.652 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.E.selectExecution - ==>  Preparing: select * from ACT_RU_EXECUTION where ID_ = ?
12:04:37.652 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.E.selectExecution - ==> Parameters: 8aed7263-013b-11ef-8d61-de9417499372(String)
12:04:37.653 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.E.selectExecution - <==    Columns: id_, rev_, root_proc_inst_id_, proc_inst_id_, business_key_, parent_id_, proc_def_id_, super_exec_, super_case_exec_, case_inst_id_, act_id_, act_inst_id_, is_active_, is_concurrent_, is_scope_, is_event_scope_, suspension_state_, cached_ent_state_, sequence_counter_, tenant_id_
12:04:37.653 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.E.selectExecution - <==        Row: 8aed7263-013b-11ef-8d61-de9417499372, 1, null, 8aebebc1-013b-11ef-8d61-de9417499372, null, 8aebebc1-013b-11ef-8d61-de9417499372, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, applicationTask, applicationTask:8aed7264-013b-11ef-8d61-de9417499372, t, f, t, f, 1, 18, 3, null
12:04:37.654 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.E.selectExecution - <==      Total: 1
12:04:37.655 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.V.selectVariablesByExecutionId - ==>  Preparing: SELECT RES.*, ( case when RES.TASK_ID_ is not null and RES.EXECUTION_ID_ is not null then EXECUTION.ACT_INST_ID_ when RES.CASE_EXECUTION_ID_ is not null then RES.CASE_EXECUTION_ID_ when EXECUTION.PARENT_ID_ is null and RES.IS_CONCURRENT_LOCAL_ = false then EXECUTION.ID_ when EXECUTION.IS_SCOPE_ = true and EXECUTION.PARENT_ID_ is not null and RES.IS_CONCURRENT_LOCAL_ = false then PARENT_EXECUTION.ACT_INST_ID_ else EXECUTION.ACT_INST_ID_ end ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE EXECUTION_ID_ = ? AND TASK_ID_ is null
12:04:37.655 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.V.selectVariablesByExecutionId - ==> Parameters: 8aed7263-013b-11ef-8d61-de9417499372(String)
12:04:37.657 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.V.selectVariablesByExecutionId - <==    Columns: id_, rev_, type_, name_, execution_id_, proc_inst_id_, proc_def_id_, case_execution_id_, case_inst_id_, task_id_, batch_id_, bytearray_id_, double_, long_, text_, text2_, var_scope_, sequence_counter_, is_concurrent_local_, tenant_id_, act_inst_id_
12:04:37.657 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.V.selectVariablesByExecutionId - <==        Row: 8aedc085-013b-11ef-8d61-de9417499372, 1, null, Input_0squklg, 8aed7263-013b-11ef-8d61-de9417499372, 8aebebc1-013b-11ef-8d61-de9417499372, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, null, null, null, null, null, null, 8aed7263-013b-11ef-8d61-de9417499372, 1, t, null, applicationTask:8aed7264-013b-11ef-8d61-de9417499372
12:04:37.658 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.V.selectVariablesByExecutionId - <==      Total: 1
12:04:37.658 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.E.selectExecutionsByProcessInstanceId - ==>  Preparing: select * from ACT_RU_EXECUTION where PROC_INST_ID_ = ?
12:04:37.658 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.E.selectExecutionsByProcessInstanceId - ==> Parameters: 8aebebc1-013b-11ef-8d61-de9417499372(String)
12:04:37.659 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.E.selectExecutionsByProcessInstanceId - <==    Columns: id_, rev_, root_proc_inst_id_, proc_inst_id_, business_key_, parent_id_, proc_def_id_, super_exec_, super_case_exec_, case_inst_id_, act_id_, act_inst_id_, is_active_, is_concurrent_, is_scope_, is_event_scope_, suspension_state_, cached_ent_state_, sequence_counter_, tenant_id_
12:04:37.659 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.E.selectExecutionsByProcessInstanceId - <==        Row: 8aebebc1-013b-11ef-8d61-de9417499372, 1, 8aebebc1-013b-11ef-8d61-de9417499372, 8aebebc1-013b-11ef-8d61-de9417499372, null, null, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, null, 8aebebc1-013b-11ef-8d61-de9417499372, f, f, t, f, 1, 0, 2, null
12:04:37.660 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.E.selectExecutionsByProcessInstanceId - <==        Row: 8aed7263-013b-11ef-8d61-de9417499372, 1, null, 8aebebc1-013b-11ef-8d61-de9417499372, null, 8aebebc1-013b-11ef-8d61-de9417499372, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, applicationTask, applicationTask:8aed7264-013b-11ef-8d61-de9417499372, t, f, t, f, 1, 18, 3, null
12:04:37.660 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.E.selectExecutionsByProcessInstanceId - <==      Total: 2
12:04:37.662 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTasksByParentTaskId - ==>  Preparing: select * from ACT_RU_TASK where PARENT_TASK_ID_ = ?
12:04:37.662 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTasksByParentTaskId - ==> Parameters: 8aeed1f7-013b-11ef-8d61-de9417499372(String)
12:04:37.663 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTasksByParentTaskId - <==      Total: 0
12:04:37.663 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.I.selectIdentityLinksByTask - ==>  Preparing: select * from ACT_RU_IDENTITYLINK where TASK_ID_ = ?
12:04:37.663 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.I.selectIdentityLinksByTask - ==> Parameters: 8aeed1f7-013b-11ef-8d61-de9417499372(String)
12:04:37.664 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.I.selectIdentityLinksByTask - <==      Total: 0
12:04:37.664 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.V.selectVariablesByTaskId - ==>  Preparing: SELECT RES.*, ( case when RES.TASK_ID_ is not null and RES.EXECUTION_ID_ is not null then EXECUTION.ACT_INST_ID_ when RES.CASE_EXECUTION_ID_ is not null then RES.CASE_EXECUTION_ID_ when EXECUTION.PARENT_ID_ is null and RES.IS_CONCURRENT_LOCAL_ = false then EXECUTION.ID_ when EXECUTION.IS_SCOPE_ = true and EXECUTION.PARENT_ID_ is not null and RES.IS_CONCURRENT_LOCAL_ = false then PARENT_EXECUTION.ACT_INST_ID_ else EXECUTION.ACT_INST_ID_ end ) ACT_INST_ID_ FROM ACT_RU_VARIABLE RES LEFT JOIN ACT_RU_EXECUTION EXECUTION ON RES.EXECUTION_ID_ = EXECUTION.ID_ LEFT JOIN ACT_RU_EXECUTION PARENT_EXECUTION ON EXECUTION.PARENT_ID_ = PARENT_EXECUTION.ID_ WHERE TASK_ID_ = ?
12:04:37.665 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.V.selectVariablesByTaskId - ==> Parameters: 8aeed1f7-013b-11ef-8d61-de9417499372(String)
12:04:37.665 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.V.selectVariablesByTaskId - <==      Total: 0
12:04:37.666 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.H.selectHistoricTaskInstanceEvent - ==>  Preparing: select HTI.START_TIME_ from ACT_HI_TASKINST HTI where HTI.ID_ = ?
12:04:37.666 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.H.selectHistoricTaskInstanceEvent - ==> Parameters: 8aeed1f7-013b-11ef-8d61-de9417499372(String)
12:04:37.667 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.H.selectHistoricTaskInstanceEvent - <==    Columns: start_time_
12:04:37.667 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.H.selectHistoricTaskInstanceEvent - <==        Row: 2024-04-23 12:04:31.74
12:04:37.667 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.H.selectHistoricTaskInstanceEvent - <==      Total: 1
12:04:37.667 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTasksByExecutionId - ==>  Preparing: select distinct T.* from ACT_RU_TASK T where T.EXECUTION_ID_ = ?
12:04:37.667 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTasksByExecutionId - ==> Parameters: 8aed7263-013b-11ef-8d61-de9417499372(String)
12:04:37.668 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.T.selectTasksByExecutionId - <==    Columns: id_, rev_, execution_id_, proc_inst_id_, proc_def_id_, case_execution_id_, case_inst_id_, case_def_id_, name_, parent_task_id_, description_, task_def_key_, owner_, assignee_, delegation_, priority_, create_time_, last_updated_, due_date_, follow_up_date_, suspension_state_, tenant_id_
12:04:37.668 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.T.selectTasksByExecutionId - <==        Row: 8aeed1f7-013b-11ef-8d61-de9417499372, 1, 8aed7263-013b-11ef-8d61-de9417499372, 8aebebc1-013b-11ef-8d61-de9417499372, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, Application, null, null, applicationTask, null, null, null, 50, 2024-04-23 12:04:31.738, null, null, null, 1, null
12:04:37.668 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTasksByExecutionId - <==      Total: 1
12:04:37.668 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.H.selectHistoricActivityInstanceEvent - ==>  Preparing: select HAI.START_TIME_ from ACT_HI_ACTINST HAI where HAI.ID_ = ?
12:04:37.668 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.H.selectHistoricActivityInstanceEvent - ==> Parameters: applicationTask:8aed7264-013b-11ef-8d61-de9417499372(String)
12:04:37.670 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.H.selectHistoricActivityInstanceEvent - <==    Columns: start_time_
12:04:37.670 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.H.selectHistoricActivityInstanceEvent - <==        Row: 2024-04-23 12:04:31.738
12:04:37.670 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.H.selectHistoricActivityInstanceEvent - <==      Total: 1
12:04:37.674 [http-nio-8080-exec-3] DEBUG org.camunda.bpm.engine.persistence - ENGINE-03030 Child execution 'ScopeExecution[8e7894fc-013b-11ef-8d61-de9417499372]' created with parent 'ProcessInstance[8aebebc1-013b-11ef-8d61-de9417499372]'.
12:04:37.674 [http-nio-8080-exec-3] DEBUG org.camunda.bpm.engine.persistence - ENGINE-03031 Initializing execution 'ScopeExecution[8e7894fc-013b-11ef-8d61-de9417499372]'
12:04:37.674 [http-nio-8080-exec-3] DEBUG org.camunda.bpm.engine.persistence - ENGINE-03032 Initializing timer declaration 'ScopeExecution[8e7894fc-013b-11ef-8d61-de9417499372]'
12:04:37.676 [http-nio-8080-exec-3] DEBUG o.s.j.support.JdbcTransactionManager - Participating in existing transaction
12:04:37.678 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - ==>  Preparing: select distinct RES.REV_, RES.ID_, RES.NAME_, RES.PARENT_TASK_ID_, RES.DESCRIPTION_, RES.PRIORITY_, RES.CREATE_TIME_, RES.OWNER_, RES.ASSIGNEE_, RES.DELEGATION_, RES.EXECUTION_ID_, RES.PROC_INST_ID_, RES.PROC_DEF_ID_, RES.CASE_EXECUTION_ID_, RES.CASE_INST_ID_, RES.CASE_DEF_ID_, RES.TASK_DEF_KEY_, RES.DUE_DATE_, RES.FOLLOW_UP_DATE_, RES.SUSPENSION_STATE_, RES.TENANT_ID_, RES.LAST_UPDATED_ from ACT_RU_TASK RES WHERE ( 1 = 1 and RES.SUSPENSION_STATE_ = 1 ) order by RES.ID_ asc LIMIT ? OFFSET ?
12:04:37.678 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - ==> Parameters: 2147483647(Integer), 0(Integer)
12:04:37.679 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - <==    Columns: rev_, id_, name_, parent_task_id_, description_, priority_, create_time_, owner_, assignee_, delegation_, execution_id_, proc_inst_id_, proc_def_id_, case_execution_id_, case_inst_id_, case_def_id_, task_def_key_, due_date_, follow_up_date_, suspension_state_, tenant_id_, last_updated_
12:04:37.679 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - <==        Row: 1, 8aeed1f7-013b-11ef-8d61-de9417499372, Application, null, null, 50, 2024-04-23 12:04:31.738, null, null, null, 8aed7263-013b-11ef-8d61-de9417499372, 8aebebc1-013b-11ef-8d61-de9417499372, simpleApplication:2:6b2fd620-013b-11ef-8d61-de9417499372, null, null, null, applicationTask, null, null, 1, null, null
12:04:37.680 [http-nio-8080-exec-3] TRACE o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - <==        Row: 1, fdc32436-013a-11ef-b6f7-de9417499372, Final Approval, null, null, 50, 2024-04-23 12:00:34.893, null, null, null, fdc32432-013a-11ef-b6f7-de9417499372, cae104a0-013a-11ef-b6f7-de9417499372, simpleApplication:1:e31d0c3f-0139-11ef-b6f7-de9417499372, null, null, null, approvalTask, null, null, 1, null, null
12:04:37.680 [http-nio-8080-exec-3] DEBUG o.c.b.e.i.p.e.T.selectTaskByQueryCriteria - <==      Total: 2
12:04:37.680 [http-nio-8080-exec-3] DEBUG o.s.t.support.TransactionTemplate - Initiating transaction rollback on application exception
org.camunda.bpm.engine.ProcessEngineException: Query return 2 results instead of max 1
        at org.camunda.bpm.engine.impl.AbstractQuery.executeSingleResult(AbstractQuery.java:245)

Environment:

1. Camunda: 7.21
2. Spring boot: 3.2.2
3. Databqase: Postgress