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.11k stars 1.55k forks source link

End event is not fired after cancellation for inactive execution #3916

Closed danielkelemen closed 7 months ago

danielkelemen commented 11 months ago

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

Hints

Links

Breakdown

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

Dev2QA handover

mboskamp commented 8 months ago

I will backport the PR after the 7.21 merge

mboskamp commented 7 months ago

Backports are ready