spring-projects / spring-projects/spring-batch

Step never launched when restarting a failed loop flow job [BATCH-2703]

Open
#906 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: core related-to: flow-definition status: waiting-for-triage type: bug
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

Damien Lenci opened BATCH-2703 and commented

My job is using a flow of 3 steps (A, B, C) in a loop.
When no error occurs, the job executes fine : A -> B -> C -> A -> B -> C ->...
If an error occurs on step B and I try to restart the job, I would expect the following execution :
B -> C -> A -> B -> C ->...
Instead, step A is never executed again, resulting in the execution B -> C -> B -> C -> ...

Looking at SimpleStepHandler, maybe the following behaviour shoud be extended to remove the last execution of an already skipped step :

if (stepExecutionPartOfExistingJobExecution(execution, lastStepExecution)) {
	// If the last execution of this step was in the same job, it's
	// probably intentional so we want to run it again...
	logger.info(String.format("Duplicate step [%s] detected in execution of job=[%s]. "
					+ "If either step fails, both will be executed again on restart.", step.getName(), jobInstance
					.getJobName()));
	lastStepExecution = null;
}

Affects: 3.0.7

Issue Links:

  • BATCH-2533 Restarting a job that failed before going back to a previous step is not working well

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading SimpleStepHandler and the linked BATCH-2533 context. Trace how the failed flow job selects the next step on restart, especially when a previously skipped step is encountered. Done means a restart follows B -> C -> A rather than repeatedly skipping A, while preserving the expected looping behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.