-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Fix parameters handling on a restart of a Spring Batch job #14933
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
Conversation
Before this commit, Spring Boot was calling the `getNextJobParameters` method of the `JobParametersBuilder` from batch. This method was getting the previous parameters of the wrong job instance in a restart scenario. This commit fixes the issue by first getting the right job instance with the provided parameters, then restarting it. Resolves gh-14484
@benas - I'm seeing the same behavior on a COMPLETED job. Just trying to run multiple times with a different parameter value for |
@dturanski Does your job have a job parameters incrementer? |
@benas - yes RunIdIncrementer. I will try against this PR |
The PR to batch is going to be backported so we'll rebase this PR onto 2.0.x |
I see the milestone for this PR changed to 2.0.x. Will this be merged to boot 2.1 too? The PR on batch has been merged in both the master branch for batch 4.1 (for boot 2.1) and the 4.0.x branch (for boot 2.0.x) |
@benas Yeah, we always forward merge from the maintenance branches. |
* pr/14933: Polish "Fix Spring Batch job restart parameters handling" Fix Spring Batch job restart parameters handling
Hi @benas! Thanks for the PR! Just one small detail, which I think could be simplified a bit: In a restart scenario, we calculate the job parameters as:
but, afaik, the result will be exactly the same jobParameters specified as input!! So we could use the jobParameters variable with no further calculation, right? |
@aritzbastida Please let's discuss this point on the gitter channel of Spring Batch as this PR got merged and I will explain in details the code snippet above. |
Ok, you're right. Where is that? Can you post the link? |
It is here: https://gitter.im/spring-batch/Lobby |
This PR resolves gh-14484.
Before this commit, Spring Boot was calling the
JobParametersBuilder#getNextJobParameters
method from batch. This method was getting the previous parameters of the wrong job instance in a restart scenario.
This commit fixes the issue by first getting the right job instance with the provided parameters, then restarting it if necessary.
To correctly fix the issue reported in gh-14484, a fix needs to be applied on both sides (batch and boot). This PR is coupled with the one opened against batch: spring-projects/spring-batch#660.