spring-projects / spring-batch

Spring Batch is a framework for writing batch applications using Java and Spring
http://projects.spring.io/spring-batch/
Apache License 2.0
2.7k stars 2.33k forks source link

Job operator restart failed step issue #4647

Open vatsla20 opened 1 month ago

vatsla20 commented 1 month ago

Bug description I have a spring batch job with eg : 4 steps, the second steps fails and the flow is such that I need to update details so it goes on to the 3rd and 4th steps marks them as complete. In the end of the job I update the job execution with status and exit status as failed and restart the job. Step execution :

  1. Status - completed , exitstatus - completed
  2. Status - failed , exitstatus - failed
  3. Status - completed , exitstatus - completed
  4. Status - completed , exitstatus - completed Job execution status failed and exit status failed

On restart non of the steps are executed again and the job ends successfully. I want to restart the job from the failed step.

Now if I try to fail the last 3 steps Step execution :

  1. Status - completed , exitstatus - completed
  2. Status - failed , exitstatus - failed
  3. Status - failed , exitstatus - failed
  4. Status - failed , exitstatus - failed Job execution status failed and exit status failed

Here only the step 4 is executed on the restart, it's taking only the last failed step. Environment Please provide as many details as possible: Spring batch version - 5.1.2 Java version 17

Steps to reproduce Given above

Expected behavior How can I make the job restart from the second step which is the actual failed step

fmbenhassine commented 3 weeks ago

Thank you for opening this issue. The job should restart from the first failed step (step 2 in your case). I do not exclude this to be a bug in Spring Batch, however, I would like to be able to reproduce the issue with an example.

Can you please provide a complete yet minimal example that reproduces the problem? You can start from the project template as explained in Issue Reporting Guide. Thank you upfront.