Skip to content

JobRepository.deleteJobInstance() Fails with Foreign Key Constraint Violation if Job Executions have Step Executions #4382

Closed
@Swiking94

Description

@Swiking94

Related to #4242

Bug description
Using the method deleteJobInstance from JobRepository does not work if a JobExecution still has StepExecutions

Explications from my understanding
The work done in this commit works well: when you call JobRepository.findJobExecutions() it returns the JobExecutions with all the StepExecutions

However when you call JobRepository.deleteJobInstance() the method called for retrieving the JobExecutions is not JobRepository.findJobExecutions() but this.jobExecutionDao.findJobExecutions(jobInstance) thus resulting in the abscence of the StepExecutions in the JobExecutions

Environment
Spring Batch 5.0.1

Steps to reproduce

  1. Create a new Job.
  2. Try to delete all Executions/Instances of this Job using deleteJobInstance
  3. Foreign Key Constraint Violation error occurs

Expected behavior
All objects are correctly deleted from the database using deleteJobInstance

Thanks in advance for the consideration

Activity

fmbenhassine

fmbenhassine commented on Jun 14, 2023

@fmbenhassine
Contributor

Thank you for opening this issue! We do not exclude that this could be a bug in Spring Batch. However, we would like to validate that with a minimal complete verifiable example.

Could you please take some time to create a minimal example that reproduces the problem? To help you in reporting your issue, we have prepared a project template that you can use as a starting point. Please check the Issue Reporting Guidelines for more details about this.

Thank you for your collaboration.

Swiking94

Swiking94 commented on Jul 6, 2023

@Swiking94
Author

Hi!
Thank you for your reply and consideration.

Here is the sample of reproduction
Please let me know if it is not enough or if you can't make it work

spring-batch-mcve.zip

Have a nice day

added
has: minimal-exampleBug reports that provide a minimal complete reproducible example
status: feedback-providedIssues for which the feedback requested from the reporter was provided
and removed
status: waiting-for-reporterIssues for which we are waiting for feedback from the reporter
on Jul 7, 2023
added this to the 5.2.0 milestone on Feb 15, 2024
added 2 commits that reference this issue on Feb 15, 2024
b98d1b1
36cd26f
added a commit that references this issue on Feb 16, 2024
894f9f9
modified the milestones: 5.2.0, 5.2.0-M1 on Sep 16, 2024
added a commit that references this issue on Feb 2, 2025
9f29b90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: backport-to-5.0.xIssues that will be back-ported to the 5.0.x linefor: backport-to-5.1.xIssues that will be back-ported to the 5.1.x linehas: minimal-exampleBug reports that provide a minimal complete reproducible examplein: corestatus: feedback-providedIssues for which the feedback requested from the reporter was providedtype: bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @fmbenhassine@Swiking94

      Issue actions

        JobRepository.deleteJobInstance() Fails with Foreign Key Constraint Violation if Job Executions have Step Executions · Issue #4382 · spring-projects/spring-batch