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

Add post hooks for workflow deletion #9258

Merged
merged 3 commits into from
Dec 27, 2024

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Dec 27, 2024

Delete all workflow sub objects when workflow is deleted. Other sub objects cannot be deleted otherwise.

We do not listen to deletion events so I am not adding them. Those post hooks should be deleted Q1 once we properly handle cascade for soft deletion

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Adds post-query hooks to handle cascading deletion of workflow sub-entities (versions, runs, event listeners) when workflows are deleted, serving as a temporary solution until proper soft deletion cascade is implemented.

  • Critical bug: cleanWorkflowsSubEntities in /packages/twenty-server/src/modules/workflow/common/workspace-services/workflow-common.workspace-service.ts uses incorrect entity type WorkflowVersionWorkspaceEntity for workflowRun and eventListener repositories
  • Performance issue: map() is used incorrectly for async operations without awaiting results in cleanWorkflowsSubEntities
  • Missing error handling for delete operations in cleanWorkflowsSubEntities
  • No transaction wrapping for the cascade deletion operations, risking partial deletions

4 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

@thomtrp thomtrp force-pushed the tt-delete-workflow-sub-objects-in-cascade branch from ed3c40f to 32c768b Compare December 27, 2024 11:31
Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM

'workflowEventListener',
);

workflowIds.map(async (workflowId) => {
Copy link
Member

Choose a reason for hiding this comment

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

I guess if you really want to fire-and-forget, you don't need map here but foreach instead. This won't guarantee the execution of your promises though I'd suggest using Promise.all()

@thomtrp thomtrp enabled auto-merge (squash) December 27, 2024 13:39
@thomtrp thomtrp merged commit 58c92e0 into main Dec 27, 2024
22 checks passed
@thomtrp thomtrp deleted the tt-delete-workflow-sub-objects-in-cascade branch December 27, 2024 13:40
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.

2 participants