Skip to content

4756 Fix principal_job FK violation when deleting project deployment#4767

Merged
ivicac merged 2 commits intomasterfrom
4756
Apr 15, 2026
Merged

4756 Fix principal_job FK violation when deleting project deployment#4767
ivicac merged 2 commits intomasterfrom
4756

Conversation

@ivicac
Copy link
Copy Markdown
Contributor

@ivicac ivicac commented Apr 15, 2026

Split the delete loop into two passes — delete all principal_job rows first, then delete all jobs. The previous single-pass loop deleted parent's principal_job and then called jobFacade.deleteJob(parent), which recursively deletes child jobs whose principal_job rows still existed, causing fk_principal_job_job violations.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Split the delete loop into two passes — delete all principal_job rows first, then delete all jobs. The previous single-pass loop deleted parent's principal_job and then called jobFacade.deleteJob(parent), which recursively deletes child jobs whose principal_job rows still existed, causing fk_principal_job_job violations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ivicac ivicac requested a review from Copilot April 15, 2026 05:41
@ivicac ivicac linked an issue Apr 15, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a foreign key violation (fk_principal_job_job) when deleting a project deployment/integration instance by ensuring principal_job rows are deleted for all associated jobs before any job rows are deleted (preventing recursive job deletion from encountering still-referenced principal_job records).

Changes:

  • Split deployment/config deletion into two passes: (1) delete principal_job rows for all job IDs, then (2) delete the jobs.
  • Add an integration test to assert the intended ordering in ProjectDeploymentFacade deletion.
  • Add an integration test in atlas-execution-service to validate that JobFacade.deleteJob deletes child jobs and task executions recursively; extend test wiring/dependencies accordingly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/libs/automation/automation-configuration/automation-configuration-service/src/main/java/com/bytechef/automation/configuration/facade/ProjectDeploymentFacadeImpl.java Two-pass deletion to remove principal_job rows before deleting jobs.
server/libs/automation/automation-configuration/automation-configuration-service/src/test/java/com/bytechef/automation/configuration/facade/ProjectDeploymentFacadeIntTest.java Adds test asserting principal-job deletion ordering vs job deletion.
server/ee/libs/embedded/embedded-configuration/embedded-configuration-service/src/main/java/com/bytechef/ee/embedded/configuration/facade/IntegrationInstanceConfigurationFacadeImpl.java Mirrors the two-pass deletion fix for embedded integration instance configurations.
server/libs/atlas/atlas-execution/atlas-execution-service/src/test/java/com/bytechef/atlas/execution/facade/JobFacadeIntTest.java Adds recursive delete integration test + required JDBC converter wiring.
server/libs/atlas/atlas-execution/atlas-execution-service/build.gradle.kts Adds test dependencies needed by the new integration test wiring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jobFacade.deleteJob recursively deletes child jobs, so iterating a flat jobIds list that contains both parents and children revisits already-deleted rows. Sort by id descending (children have larger ids since they are inserted later) and de-dup before the delete loop. Loosen the ordering assertion in the deployment test accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ivicac ivicac merged commit 15b8fbd into master Apr 15, 2026
4 of 5 checks passed
@ivicac ivicac deleted the 4756 branch April 15, 2026 07:16
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.

[bug] Cannot delete deployment with subflow

2 participants