Skip to content

Remove historic entity link orphans on task, process and case deletion#4208

Merged
filiphr merged 1 commit intoflowable:mainfrom
filiphr:fix/historic-entity-link-reference-scope-cleanup
May 5, 2026
Merged

Remove historic entity link orphans on task, process and case deletion#4208
filiphr merged 1 commit intoflowable:mainfrom
filiphr:fix/historic-entity-link-reference-scope-cleanup

Conversation

@filiphr
Copy link
Copy Markdown
Contributor

@filiphr filiphr commented May 5, 2026

Historic entity-link cleanup only deleted rows where the deleted entity appeared as the SCOPE_ID_, leaving orphan rows where it appeared as the REFERENCE_SCOPE_ID_. Subsequent reads of those links could return entries pointing at scopes that no longer exist.

Add deleteHistoricEntityLinksByScopeIdOrReferenceScopeIdAndScopeType and bulkDeleteHistoricEntityLinksForScopeTypeAndScopeIdsOrReferenceScopeIds on HistoricEntityLinkService and use them from
TaskHelper#deleteHistoricTask (BPMN and CMMN, single and bulk), DefaultHistoryManager#recordProcessInstanceDeleted / recordBulkDeleteProcessInstances,
DefaultCmmnHistoryManager#recordHistoricCaseInstanceDeleted, and CmmnHistoryHelper#bulkDeleteHistoricCaseInstances. A single SQL delete now removes every row mentioning the deleted entity in either direction.

Historic entity-link cleanup only deleted rows where the deleted entity
appeared as the SCOPE_ID_, leaving orphan rows where it appeared as the
REFERENCE_SCOPE_ID_. Subsequent reads of those links could return entries
pointing at scopes that no longer exist.

Add deleteHistoricEntityLinksByScopeIdOrReferenceScopeIdAndScopeType and
bulkDeleteHistoricEntityLinksForScopeTypeAndScopeIdsOrReferenceScopeIds
on HistoricEntityLinkService and use them from
TaskHelper#deleteHistoricTask (BPMN and CMMN, single and bulk),
DefaultHistoryManager#recordProcessInstanceDeleted /
recordBulkDeleteProcessInstances,
DefaultCmmnHistoryManager#recordHistoricCaseInstanceDeleted, and
CmmnHistoryHelper#bulkDeleteHistoricCaseInstances. A single SQL delete
now removes every row mentioning the deleted entity in either direction.
@filiphr filiphr merged commit fd1c4fc into flowable:main May 5, 2026
3 checks passed
@filiphr filiphr deleted the fix/historic-entity-link-reference-scope-cleanup branch May 5, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant