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

Default ON DELETE RESTRICT in MySQL schema causes trouble with JobRepositoryTestUtils #4322

Closed
flozano opened this issue Mar 8, 2023 · 2 comments
Labels
status: superseded Issues that are superseded by other issues

Comments

@flozano
Copy link

flozano commented Mar 8, 2023

In MySQL schema:
https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql

a FK is defined with default cascade behaviour (ON DELETE RESTRICT):

	constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID)
	references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)

However, https://github.com/spring-projects/spring-batch/blob/main/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java doesn't take care of cleaning the dependant rows, and a failure is caused when used:

org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [DELETE FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID = ?]; Cannot delete or update a parent row: a foreign key constraint fails (`test`.`BATCH_STEP_EXECUTION`, CONSTRAINT `JOB_EXEC_STEP_FK` FOREIGN KEY (`JOB_EXECUTION_ID`) REFERENCES `BATCH_JOB_EXECUTION` (`JOB_EXECUTION_ID`))
@flozano flozano added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Mar 8, 2023
@fmbenhassine
Copy link
Contributor

Thank you for reporting this issue. Which Spring Batch version do you use?

I believe this has been fixed in #4249. Can you please check with v5.0.1? If the issue persists with 5.0.1, could you please provide a minimal example or a failing test (we have a Docker based integration test for MySQL here)? Thank you upfront.

@fmbenhassine fmbenhassine added status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter and removed status: waiting-for-triage Issues that we did not analyse yet labels Apr 3, 2023
@fmbenhassine
Copy link
Contributor

I am closing this issue as I believe it has been fixed in #4249 since v5.0.1. But if the problem is still present, please add a comment and we will reopen the issue for further investigation. Thank you.

@fmbenhassine fmbenhassine closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2024
@fmbenhassine fmbenhassine added status: superseded Issues that are superseded by other issues and removed status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter type: bug labels Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded Issues that are superseded by other issues
Projects
None yet
Development

No branches or pull requests

2 participants