Skip to content

Existing failed job is restarted, even if new job contains different job parameters [BATCH-2711] #882

@spring-projects-issues

Description

@spring-projects-issues

Tonie opened BATCH-2711 and commented

Created a Spring Batch job as described in the documentation 'Getting Started - Creating a Batch Service' (https://spring.io/guides/gs/batch-processing/) in order to show the issue. SQLServer is used as database for the meta-data tables as well as the business data table.

The job reads a .csv file with with 6 records and the ItemProcess throws an exception on the 4th record. The job then stops and the meta-data tables are updated correctly. Job parameters used for the job is: parm=0 fileName=error.csv

After this a new job is started with the same job name, but different parameters: parm=1 fileName=new.csv. What happens is that Spring Batch restart the failed job with the errors again. Even if the new job contains different parameters.

This worked perfectly as expected in version 3.0.8, but the issue occurred when upgraded to version 4.0.1.

Logs from 3.0.8 shows the following:

main] o.s.b.a.b.JobLauncherCommandLineRunner   : Running default command line with: [param=1, inputFile=sample-data-1.csv]
main] o.s.b.c.r.s.JobRepositoryFactoryBean     : No database type set, using meta data indicating: SQLSERVER
main] o.s.b.c.l.support.SimpleJobLauncher      : No TaskExecutor has been set, defaulting to synchronous executor.
main] o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=importUserJob]] launched with the following parameters: [inputFile=sample-data-1.csv, run.id=1, param=1]

Logs from 4.0.1 shows the following:

main] o.s.b.c.r.s.JobRepositoryFactoryBean     : No database type set, using meta data indicating: SQLSERVER
main] o.s.b.c.l.support.SimpleJobLauncher      : No TaskExecutor has been set, defaulting to synchronous executor.
main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
main] hello.Application                        : Started Application in 2.157 seconds (JVM running for 2.592)
main] o.s.b.a.b.JobLauncherCommandLineRunner   : Running default command line with: [param=1, inputFile=sample-data-1.csv]
main] o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=importUserJob]] launched with the following parameters: [{inputFile=sample-data-error.csv, param=0, run.id=1}]

Notice the difference in parameters used in SimpleJobLauncher, even if JobLauncherCommandLineRunner in both cases show the same correct parameters.


Affects: 4.0.1

Issue Links:

  • BATCH-2741 Job Parameter Overwrite Issue
    ("is duplicated by")

Referenced from: commits ebf156d, 5328fb2

Backported to: 4.0.2

4 votes, 8 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    has: backportsLegacy label from JIRA. Superseded by "for: backport-to-x.x.x"in: coretype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions