-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
In a project in which I am working now we are using an specific parameter as identifier and without incrementer in a restartable job. The problem that we are facing now is that when we try to launch a new job with a new identifier argument a previous job instance is retrieved, let me explain it:
- we have a job restartable with a specific identifier, let’s say for example a date.
- we launch the job for the date 2018-09-15 and it ends with a failed status.
- we launch the job for a new date, for example 2018-09-16, and we expect that a new job instance for 2018-09-16 would be created, but instead the job instance identified by 2018-09-15 is picked up and the identifier argument is changed to 2018-09-15.
I am not sure if I am missing something about the expected behavior but I would expect that the failed instance 2018-09-15 would be picked up only if we launch the batch with that date as argument but not that by default if a failed job instance exists that job instance is the one that is to be running in subsequent executions independently of the new arguments passed to the job.
I have tracked the problem to here: JobLauncherCommandLineRunner, it seems that the JobLauncherCommandLineRunner
uses the JobParametersBuilder
from Spring Batch to pick the job parameters, but the problem is that JobParametersBuilder.getNextJobParameters()
doesn’t care about the identifier arguments of the job that it’s being launched, instead, in case of a previous failed job it picks this job instance assuming that you want to continue the previous job instance and without taking into account that you may want to launch a different instance, you can see it here: JobParametersBuilder.
I am not sure if the problem is in Spring Batch’s JobParametersBuilder
or Spring Boot’s JobLauncherCommandLineRunner
, but I think that the behavior of JobParametersBuilder.getNextJobParameters()
makes sense if you want to act given the previous job state but maybe JobLauncherCommandLineRunner
shouldn’t assume this because it is not always the case.
As I said maybe I am misunderstanding something but I think there is a bug here.
Spring Boot version: 2.0.3.RELEASE.
Spring Batch core version: 4.0.1.RELEASE.