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.03k stars 1.53k forks source link

Orphan subscriptions for conditional events are not deleted on redeployment of process definition #4396

Closed joaquinfelici closed 3 weeks ago

joaquinfelici commented 1 month ago

Environment (Required on creation)

Any

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

Whenever we have an orphan subscription for a conditional event in the database, and we try to redeploy the same process definition, the deployment succeeds (no exception will be thrown) but we end up with two subscriptions (one for the new deployment and the orphan one), as we can see below:

image

But only one process definition:

image

Steps to reproduce (Required on creation)

There's a failing test case in the PR attached to the issue to reproduce easily.

  1. Reach a scenario in which we have an orphan subscription in the DB.
  2. Redeploy the same process definition that the orphan subscription is from.
  3. Check database to see that there's two subscriptions instead of one.

Observed Behavior (Required on creation)

After redeployment, two subscriptions are present in the DB, and one of them is for a non existent process definition.

Expected behavior (Required on creation)

After redeployment we should have only one subscription for the latest definition.

Root Cause (Required on prioritization)

Whenever we deploy a process definition, we remove obsolete subscriptions based on two aspects:

However, conditional subscriptions do not have a name, so they are ignored.

Solution Ideas

Hints

Links

Breakdown

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

Dev2QA handover