Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggered event subprocess not activated after terminating boundary event #8726

Closed
remcowesterhoud opened this issue Feb 3, 2022 · 8 comments · Fixed by #11216
Closed

Triggered event subprocess not activated after terminating boundary event #8726

remcowesterhoud opened this issue Feb 3, 2022 · 8 comments · Fixed by #11216
Assignees
Labels
kind/bug Categorizes an issue or PR as a bug severity/low Marks a bug as having little to no noticeable impact for the user version:8.2.0-alpha3 version:8.2.0 Marks an issue as being completely or in parts released in 8.2.0

Comments

@remcowesterhoud
Copy link
Contributor

remcowesterhoud commented Feb 3, 2022

Describe the bug

Assume the following process:
image
If task1 is being processed and we send a message, triggering the boundary event, the subprocess will be terminated. If we send a message immediately after the first message, triggering the interrupting event subprocess, while the subprocess is being terminated this will result in the event sub process not getting activated. This means the process instance will be stuck.

Note: This also happens when the boundary event is attached to a task without a subprocess. However, since there is less processing to be done when the boundary event gets triggered it is way less likely to happen.

To Reproduce

Unit test to reproduce

  @Test
  public void reproduce() {
    final String processId = "process";
    final var process =
        Bpmn.createExecutableProcess(processId)
            .eventSubProcess(
                "eventSP",
                s ->
                    s.startEvent("eventSPStart")
                        .interrupting(true)
                        .message(
                            m -> m.name("eventMessage").zeebeCorrelationKey("=\"eventMessage\""))
                        .endEvent())
            .startEvent("start")
            .subProcess("sp")
            .embeddedSubProcess()
            .startEvent("spStart")
            .serviceTask("task1", t -> t.zeebeJobType("t1"))
            .endEvent()
            .subProcessDone()
            .boundaryEvent(
                "boundary",
                b -> b.message(m -> m.name("bMessage").zeebeCorrelationKey("=\"bMessage\"")))
            .serviceTask("task2", t -> t.zeebeJobType("t2"))
            .endEvent()
            .moveToActivity("sp")
            .endEvent()
            .done();

    ENGINE.deployment().withXmlResource(process).deploy();
    ENGINE.processInstance().ofBpmnProcessId(processId).create();
    RecordingExporter.jobRecords().withElementId("task1").await();
    ENGINE.message().withName("bMessage").withCorrelationKey("bMessage").publish();
    ENGINE.message().withName("eventMessage").withCorrelationKey("eventMessage").publish();

    assertThat(
            RecordingExporter.processInstanceRecords()
                .withElementType(BpmnElementType.END_EVENT)
                .exists())
        .isTrue();
  }

Expected behavior

I would expect the boundary event to get terminated (along with task1 and the subprocess) once the event subprocess gets triggered. The event sub process should then complete as expected.

Log/Stacktrace

Full Stacktrace

C DEPLOYMENT         CREATE         - #01-> -1  -1 - 
E PROC               CREATED        - #02->#01 K01 - process.xml -> "process" (version:1)
E DEPLOYMENT         CREATED        - #03->#01 K02 - process.xml
E DEPLOYMENT         FULLY_DISTR    - #04->#01 K02 - 
C PROC_INST_CREATION CREATE         - #05-> -1  -1 - new <process "process"> (no vars)
C PROC_INST          ACTIVATE       - #06->#05 K03 - PROCESS "process" in <process "process"[K03]>
E PROC_INST_CREATION CREATED        - #07->#05 K04 - new <process "process"> (no vars)
E PROC_INST          ACTIVATING     - #08->#06 K03 - PROCESS "process" in <process "process"[K03]>
E PROC_MSG_SUB       CREATING       - #09->#06 K05 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
E PROC_INST          ACTIVATED      - #10->#06 K03 - PROCESS "process" in <process "process"[K03]>
C PROC_INST          ACTIVATE       - #11->#06  -1 - START_EVENT "start" in <process "process"[K03]>
C MSG_SUB            CREATE         - #12-> -1  -1 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
E PROC_INST          ACTIVATING     - #13->#11 K06 - START_EVENT "start" in <process "process"[K03]>
E PROC_INST          ACTIVATED      - #14->#11 K06 - START_EVENT "start" in <process "process"[K03]>
C PROC_INST          COMPLETE       - #15->#11 K06 - START_EVENT "start" in <process "process"[K03]>
E MSG_SUB            CREATED        - #16->#12 K07 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
C PROC_MSG_SUB       CREATE         - #17-> -1  -1 - "eventMessage" (inter.) @[K03] in <process ?[K03]> (no vars)
E PROC_INST          COMPLETING     - #18->#15 K06 - START_EVENT "start" in <process "process"[K03]>
E PROC_INST          COMPLETED      - #19->#15 K06 - START_EVENT "start" in <process "process"[K03]>
E PROC_INST          SEQ_FLOW_TAKEN - #20->#15 K08 - SEQUENCE_FLOW "sequenc..64b0258" in <process "process"[K03]>
C PROC_INST          ACTIVATE       - #21->#15 K09 - SUB_PROCESS "sp" in <process "process"[K03]>
E PROC_MSG_SUB       CREATED        - #22->#17 K05 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
E PROC_INST          ACTIVATING     - #23->#21 K09 - SUB_PROCESS "sp" in <process "process"[K03]>
E PROC_MSG_SUB       CREATING       - #24->#21 K10 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
E PROC_INST          ACTIVATED      - #25->#21 K09 - SUB_PROCESS "sp" in <process "process"[K03]>
C PROC_INST          ACTIVATE       - #26->#21  -1 - START_EVENT "spStart" in <process "process"[K03]>
C MSG_SUB            CREATE         - #27-> -1  -1 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
E PROC_INST          ACTIVATING     - #28->#26 K11 - START_EVENT "spStart" in <process "process"[K03]>
E PROC_INST          ACTIVATED      - #29->#26 K11 - START_EVENT "spStart" in <process "process"[K03]>
C PROC_INST          COMPLETE       - #30->#26 K11 - START_EVENT "spStart" in <process "process"[K03]>
E MSG_SUB            CREATED        - #31->#27 K12 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
C PROC_MSG_SUB       CREATE         - #32-> -1  -1 - "bMessage" (inter.) @[K09] in <process ?[K03]> (no vars)
E PROC_INST          COMPLETING     - #33->#30 K11 - START_EVENT "spStart" in <process "process"[K03]>
E PROC_INST          COMPLETED      - #34->#30 K11 - START_EVENT "spStart" in <process "process"[K03]>
E PROC_INST          SEQ_FLOW_TAKEN - #35->#30 K13 - SEQUENCE_FLOW "sequenc..5e9078f" in <process "process"[K03]>
C PROC_INST          ACTIVATE       - #36->#30 K14 - SERVICE_TASK "task1" in <process "process"[K03]>
E PROC_MSG_SUB       CREATED        - #37->#32 K10 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
E PROC_INST          ACTIVATING     - #38->#36 K14 - SERVICE_TASK "task1" in <process "process"[K03]>
E JOB                CREATED        - #39->#36 K15 - K15 "t1" @"task1"[K14] 3 retries, in <process "process"[K03]> (no vars)
E PROC_INST          ACTIVATED      - #40->#36 K14 - SERVICE_TASK "task1" in <process "process"[K03]>
C MSG                PUBLISH        - #41-> -1  -1 - "bMessage" correlationKey: bMessage (no vars)
E MSG                PUBLISHED      - #42->#41 K16 - "bMessage" correlationKey: bMessage (no vars)
E MSG_SUB            CORRELATING    - #43->#41 K12 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
C PROC_MSG_SUB       CORRELATE      - #44-> -1  -1 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
C MSG                PUBLISH        - #45-> -1  -1 - "eventMessage" correlationKey: eventMessage (no vars)
E PROC_MSG_SUB       CORRELATED     - #46->#44 K10 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
E PROC_EVNT          TRIGGERING     - #47->#44 K17 -  @"boundary"[K09] in <process K01[K03]> (no vars)
C PROC_INST          TERMINATE      - #48->#44 K09 - SUB_PROCESS "sp" in <process "process"[K03]>
C MSG_SUB            CORRELATE      - #49-> -1  -1 - "bMessage" (inter.) @[K09] in <process "process"[K03]> (no vars)
E MSG                PUBLISHED      - #50->#45 K18 - "eventMessage" correlationKey: eventMessage (no vars)
E MSG_SUB            CORRELATING    - #51->#45 K07 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
C PROC_MSG_SUB       CORRELATE      - #52-> -1  -1 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
E PROC_INST          TERMINATING    - #53->#48 K09 - SUB_PROCESS "sp" in <process "process"[K03]>
C PROC_INST          TERMINATE      - #54->#48 K14 - SERVICE_TASK "task1" in <process "process"[K03]>
E MSG_SUB            CORRELATED     - #55->#49 K12 - "bMessage" (inter.) correlationKey: bMessage @[K09] in <process "process"[K03]> (no vars)
E PROC_MSG_SUB       CORRELATED     - #56->#52 K05 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
E PROC_EVNT          TRIGGERING     - #57->#52 K19 -  @"eventSPStart"[K03] in <process K01[K03]> (no vars)
C MSG_SUB            CORRELATE      - #58-> -1  -1 - "eventMessage" (inter.) @[K03] in <process "process"[K03]> (no vars)
E PROC_INST          TERMINATING    - #59->#54 K14 - SERVICE_TASK "task1" in <process "process"[K03]>
C JOB                CANCEL         - #60->#54 K15 - K15 "t1" @"task1"[K14] 3 retries, in <process "process"[K03]> (no vars)
E PROC_INST          TERMINATED     - #61->#54 K14 - SERVICE_TASK "task1" in <process "process"[K03]>
E PROC_INST          TERMINATED     - #62->#54 K09 - SUB_PROCESS "sp" in <process "process"[K03]>
E PROC_EVNT          TRIGGERED      - #63->#54 K17 -  @"boundary"[K09] in <process K01[K03]> (no vars)
E PROC_INST          ACTIVATING     - #64->#54 K20 - BOUNDARY_EVENT "boundary" in <process "process"[K03]>
E PROC_INST          ACTIVATED      - #65->#54 K20 - BOUNDARY_EVENT "boundary" in <process "process"[K03]>
C PROC_INST          COMPLETE       - #66->#54 K20 - BOUNDARY_EVENT "boundary" in <process "process"[K03]>
E MSG_SUB            CORRELATED     - #67->#58 K07 - "eventMessage" (inter.) correlationKey: eventMessage @[K03] in <process "process"[K03]> (no vars)
E JOB                CANCELED       - #68->#60 K15 - K15 "t1" @"task1"[K14] 3 retries, in <process "process"[K03]> (no vars)
R PROC_INST          COMPLETE       - #69->#66 K20 - BOUNDARY_EVENT "boundary" in <process "process"[K03]> !INVALID_STATE (Expected flow scope instance to be not interrupted but was interrupted by an event with id 'eventSP'.)

Environment:

  • OS: Camunda Cloud
  • Zeebe Version: 1.3.3 (probably also lower versions)

Causes #6957

@nikku
Copy link
Member

nikku commented Feb 3, 2022

If we send a message immediately after the first message, triggering the interrupting event subprocess

What is your expected behavior? Shall the event-sub-process still be activatable despite the sub-process being canceled?

@remcowesterhoud
Copy link
Contributor Author

remcowesterhoud commented Feb 3, 2022

@nikku Oops, I forgot to add it to the issue. I've added it now:

I would expect the boundary event to get terminated (along with task1 and the subprocess) once the event subprocess gets triggered. The event sub process should then complete as expected.

@nikku
Copy link
Member

nikku commented Feb 3, 2022

@remcowesterhoud Thanks!

Whether the event sub-process signals depends on if it is the same message arriving. From the BPMN standard perspective (as I understood it):

  • Event-subprocesses are only activated on non-dead scopes (non-terminated sub-process).
  • Interupting boundary event immediately terminates sub-process => The moment an interupting boundary event activates no other elements in the scope it is attached to sub process shall be activatable with events
  • If both, interrupting event sub-process and interrupting boundary event, subscribed to the same message the event sub-process catches the message first and can "absorb" it or re-throw.

In a picture (cf. error event-sub-process):

capture quKXRV_optimized

REF.

@npepinpe npepinpe added the severity/low Marks a bug as having little to no noticeable impact for the user label Feb 8, 2022
@npepinpe
Copy link
Member

npepinpe commented Feb 8, 2022

Impact seems low, the instance can be cancelled, and the desired behavior was to already interrupt the process. There is an additional developer-only impact for us, which is some tests may end up being marked as flaky. Since it seems very rare, we can postpone this for a little bit, but the next time it does, let's fix this bug and avoid spending more time investigating what seems to be flaky tests.

@korthout
Copy link
Member

Marking priority as later because (while we should avoid workflow execution related bugs) a workaround will come available with #9570.

Please comment if you think this should have a higher priority.

@saig0
Copy link
Member

saig0 commented Sep 22, 2022

I'm increasing the priority of this issue because it can lead to failing builds (e.g. #10445). And, as a result of the bug, the process instance is stuck. Even with modification, it is not clear what the process instance can be "repaired" (because the process instance is in the state interrupted).

We should work on the issue as soon as possible.

During the bug fix, we should ensure that the randomize tests with the given seeds of #10445 don't fail anymore.

@korthout
Copy link
Member

korthout commented Dec 9, 2022

@remcowesterhoud Please verify whether your recent changes resolved this issue

@remcowesterhoud
Copy link
Contributor Author

#11216 should fix this issue. I will add this as one of the issues that is closed by this.

@ghost ghost closed this as completed in 36c0947 Dec 15, 2022
@npepinpe npepinpe added the version:8.2.0 Marks an issue as being completely or in parts released in 8.2.0 label Apr 5, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes an issue or PR as a bug severity/low Marks a bug as having little to no noticeable impact for the user version:8.2.0-alpha3 version:8.2.0 Marks an issue as being completely or in parts released in 8.2.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants