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

Event subprocess attaches to inner instance of multi-instance only #12877

Conversation

korthout
Copy link
Member

@korthout korthout commented May 26, 2023

Description

Event sub processes inside a multi-instance sub process would be attached to the multi-instance body in addition to the inner instance. However, there is no reason why an event sub process should be attached to the multi-instance body. Instead, event sub processes should only be attached to the inner instances.

Example scenario

The parallel multi-instance sub process creates an item variable as input element in each inner instance.
Screenshot 2023-05-26 at 18 25 08

Each message event sub process subscribes to the same message with a correlation key expression that uses the input element variable item.
Screenshot 2023-05-26 at 18 25 39

The bug will surface as an incident on the multi-instance body stating:

failed to evaluate expression 'item.id': no variable found for name 'item'

This was because we attempted to subscribe to the event sub process already when activating the multi-instance body, and before activating any of the inner instances.

The problem is resolved by no longer attaching the event sub process to the multi-instance body.

Related issues

closes #11578

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Other teams:
If the change impacts another team an issue has been created for this team, explaining what they need to do to support this change.

Please refer to our review guidelines.

An event sub process existing inside a multi-instance sub process should
exist for each inner instance of the multi-instance. Each event sub
process should be able to be triggered individually.

There was a bug #11578, where the
event sub process's message start event could not create a message
subscription because the correlation key expression referred to the
input element. The input element exists on each inner instance, but the
engine attempted to subscribe to the event sub process before activating
any of the inner instances. In turn, this also means that the event sub
processes couldn't be triggered.

Instead of testing that we can subscribe to each event sub process, it
makes more sense to also test that we can trigger each individually.
This tests the reason why we want to be able to subscribe in the first
place.
The event sub process should only be attached to the inner instance of
the multi-instance marked element. Not to the body.

The event sub process should be triggered for a specific instance of a
multi-instance marked element only. It only exists in the flow scope of
the inner instance, not in the flow scope of the multi-instance body.

There was a bug #11578 with this
as the root problem. It surfaced because the event sub process's start
event had a correlation key expression that referred to the input
element as variable. That variable had not yet been created when we
subscribed the multi-instance body to the event sub process. We should
not have attempted to subscribe the multi-instance body to the event sub
process. Instead, each inner instance of the multi-instance should be
subscribed to its own instance of the event sub process.

See the previous commit for a test case with that scenario.
@korthout korthout marked this pull request as ready for review May 26, 2023 16:34
@korthout korthout added backport stable/8.0 backport stable/8.2 Backport a pull request to 8.2.x labels May 26, 2023
@korthout korthout requested a review from saig0 May 26, 2023 16:36
@korthout
Copy link
Member Author

korthout commented May 26, 2023

@saig0 The fix for this bug was removing a line of code you added purposefully in another pull request:

Do you have a chance to review this?

Copy link
Member

@saig0 saig0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@korthout nice catch. 👍

It works. 🎉 I guess that something else changed since my original fix. 😅

bors merge

zeebe-bors-camunda bot added a commit that referenced this pull request May 30, 2023
12877: Event subprocess attaches to inner instance of multi-instance only r=saig0 a=korthout

## Description

<!-- Please explain the changes you made here. -->

Event sub processes inside a multi-instance sub process would be attached to the multi-instance body in addition to the inner instance. However, there is no reason why an event sub process should be attached to the multi-instance body. Instead, event sub processes should only be attached to the inner instances.

**Example scenario**

The parallel multi-instance sub process creates an `item` variable as input element in each inner instance.
<img width="865" alt="Screenshot 2023-05-26 at 18 25 08" src="https://github.com/camunda/zeebe/assets/3511026/cf37717b-50cf-4478-84d3-d32009f54972">

Each message event sub process subscribes to the same message with a correlation key expression that uses the input element variable `item`.
<img width="922" alt="Screenshot 2023-05-26 at 18 25 39" src="https://github.com/camunda/zeebe/assets/3511026/9fc40f17-a2e7-4628-a9fd-a70cb6bffe90">

The bug will surface as an incident on the multi-instance body stating:

>failed to evaluate expression 'item.id': no variable found for name 'item'

This was because we attempted to subscribe to the event sub process already when activating the multi-instance body, and **before** activating any of the inner instances.

The problem is resolved by no longer attaching the event sub process to the multi-instance body.

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #11578



Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed:

@korthout
Copy link
Member Author

zeebe-bors-camunda bot added a commit that referenced this pull request May 30, 2023
12698: Replace go-bindata with go's embed FS r=npepinpe a=npepinpe

## Description

Took some slack time to complete this quick win: replaces usage of go-bindata, an external tool dependency, with the built-in capabilities of the go compiler using `go:embed` and the
embedFS.

The version file is embedded at build time into the binary, much like when we used go-bindata, and read back as a package field.

## Related issues

closes #6034 



12868: fix(journal): avoid gaps in logs due to reset r=npepinpe a=npepinpe

## Description

Avoid gaps in the log when resetting the log by deleting the segments in reverse order. This may cause data loss, but that's acceptable in the context of a reset operation. Deleting segments in reverse order will ensure we have no gaps between the remaining snapshot and segments should the operation fail midway.

Note that this does not make persisting a new snapshot/reseting the log atomic unfortunately.

Unfortunately tests were also not ideal, and require heavy use of mocks. It's also not possible to write integration test without major refactoring. As this is a quick fix, the hope is that the proper solution to make the Raft install operation atomic will redeem this.

Not marked as closing the original issue because this is, after all, a quick fix. It only fixes a specific case we're aware of.

## Related issues

<!-- Which issues are closed by this PR or are related -->

related to #12754 



12877: Event subprocess attaches to inner instance of multi-instance only r=saig0 a=korthout

## Description

<!-- Please explain the changes you made here. -->

Event sub processes inside a multi-instance sub process would be attached to the multi-instance body in addition to the inner instance. However, there is no reason why an event sub process should be attached to the multi-instance body. Instead, event sub processes should only be attached to the inner instances.

**Example scenario**

The parallel multi-instance sub process creates an `item` variable as input element in each inner instance.
<img width="865" alt="Screenshot 2023-05-26 at 18 25 08" src="https://github.com/camunda/zeebe/assets/3511026/cf37717b-50cf-4478-84d3-d32009f54972">

Each message event sub process subscribes to the same message with a correlation key expression that uses the input element variable `item`.
<img width="922" alt="Screenshot 2023-05-26 at 18 25 39" src="https://github.com/camunda/zeebe/assets/3511026/9fc40f17-a2e7-4628-a9fd-a70cb6bffe90">

The bug will surface as an incident on the multi-instance body stating:

>failed to evaluate expression 'item.id': no variable found for name 'item'

This was because we attempted to subscribe to the event sub process already when activating the multi-instance body, and **before** activating any of the inner instances.

The problem is resolved by no longer attaching the event sub process to the multi-instance body.

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #11578



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed (retrying...):

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit fdcb0d1 into main May 30, 2023
35 checks passed
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the korthout-11578-event-subprocess-attached-to-multi-instance-body branch May 30, 2023 13:39
@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.0:

@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.1:

@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.2:

zeebe-bors-camunda bot added a commit that referenced this pull request May 30, 2023
12893: [Backport stable/8.2] Event subprocess attaches to inner instance of multi-instance only r=korthout a=backport-action

# Description
Backport of #12877 to `stable/8.2`.

relates to #11578

Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
zeebe-bors-camunda bot added a commit that referenced this pull request May 30, 2023
12892: [Backport stable/8.1] Event subprocess attaches to inner instance of multi-instance only r=korthout a=backport-action

# Description
Backport of #12877 to `stable/8.1`.

relates to #11578

Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
zeebe-bors-camunda bot added a commit that referenced this pull request May 30, 2023
12890: [Backport stable/8.0] Event subprocess attaches to inner instance of multi-instance only r=korthout a=backport-action

# Description
Backport of #12877 to `stable/8.0`.

relates to #11578

Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
zeebe-bors-camunda bot added a commit that referenced this pull request May 30, 2023
12892: [Backport stable/8.1] Event subprocess attaches to inner instance of multi-instance only r=korthout a=backport-action

# Description
Backport of #12877 to `stable/8.1`.

relates to #11578

Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
zeebe-bors-camunda bot added a commit that referenced this pull request May 31, 2023
12890: [Backport stable/8.0] Event subprocess attaches to inner instance of multi-instance only r=korthout a=backport-action

# Description
Backport of #12877 to `stable/8.0`.

relates to #11578

12908: [Backport stable/8.0] Remove JDK 8 specific build r=oleschoenburg a=npepinpe

## Description

This PR backports removing the JDK 8 build, and upgrading Mockito to 5.

## Related issues

backport #12533



Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ole Schönburg <ole.schoenburg@gmail.com>
@lenaschoenburg lenaschoenburg added version:8.1.13 Marks an issue as being completely or in parts released in 8.1.13 version:8.2.6 Marks an issue as being completely or in parts released in 8.2.6 labels Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport stable/8.2 Backport a pull request to 8.2.x version:8.1.13 Marks an issue as being completely or in parts released in 8.1.13 version:8.2.6 Marks an issue as being completely or in parts released in 8.2.6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-Instance with messageevent-based subprocess that uses inputElement as correlationKey fails
4 participants