camunda-bpm-platform icon indicating copy to clipboard operation
camunda-bpm-platform copied to clipboard

End event is not fired after cancellation for inactive execution

Open danielkelemen opened this issue 1 year ago • 1 comments

Environment (Required on creation)

All supported versions.

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

In an edge case of chaining multiple activity cancellations, the history activity instance endTime is not set. This is an edge case with splitting and merging parallel gateways and two activity cancellations.

Steps to reproduce (Required on creation)

  1. Create and start a process with two parallel gateways (splitting and merging) with two sequence flows. One flow contains a wait state (e.g. intermediate event), while the other sequence flow will finish without wait states (see image). There will be two tokens. One is on the merging gateway, and one is on the intermediate catch event (waiting for a message).
  2. Cancel the intermediate event activity first, then cancel the merging parallel gateway activity.
  3. The history activity instance of the merging parallel gateway won't have endTime set. The activity end is not fired and the history producer is not triggered.

Process model: image

Observed Behavior (Required on creation)

The activity end is not fired, thus the history producer is not triggered. The history activity instance of the second parallel gateway won't have endTime set.

Expected behavior (Required on creation)

The activity end is fired, and the history producer is triggered. The history activity instance of the second parallel gateway has endTime set.

Root Cause (Required on prioritization)

After the first cancellation, the execution tree is compacted, so that the root process points to the merging gateway activity. The parallel gateway is executed, which deactivates the execution, and the gateway can't complete, since it is waiting for one more execution to join but the missing execution has been canceled (and pruned). The second cancellation cancels "Gateway_out", but since the execution is not active anymore, no end event is sent. Without an event, the history producer is not triggered and no endTime is set.

Executions

Initial executions:

- ProcessInstance[5]
    - ConcurrentExecution[8] - "Gateway_out"
    - ConcurrentExecution[9]
        - ScopeExecution[11] - "Event_Wait"

After canceling "Event_Wait" and pruning concurrent child:

- ProcessInstance[5] - "Gateway_out"

Solution Ideas

  • Fire end event if there is a cancellation, even if the execution is not active anymore. See linked PR.
  • Avoid an execution tree compaction where a gateway ends up in a situation where it can't meaningfully continue.

Hints

Links

  • https://jira.camunda.com/browse/SUPPORT-18988

Breakdown

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

Dev2QA handover

  • [ ] Does this ticket need a QA test and the testing goals are not clear from the description? Add a Dev2QA handover comment

danielkelemen avatar Nov 06 '23 13:11 danielkelemen

I will backport the PR after the 7.21 merge

mboskamp avatar Feb 22 '24 14:02 mboskamp

Backports are ready

mboskamp avatar Feb 26 '24 07:02 mboskamp