spring-projects / spring-projects/spring-batch

Partitioned step is not re-executed when Exception was thrown in Partitioner

Open
#4,736 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug description

A partitioned Step fails if an Exception is thrown from Partitioner.partition(). On retry Partitioner.partition() does not throw an exception and returns a valid partition map, but the partitioned Step does not run.

Environment
Spring Batch 5.1.2

Steps to reproduce

Define a partitioned step like this:

return new StepBuilder("partitionStep", jobRepository)
                .partitioner("myPartitioner", myPartitioner)
                .step(myStep)
                .gridSize(10)
                .build();

Implement a custom myPartitioner. It is possible that an Exception ist thrown from its partition() method.

After the retry the contents of BATCH_STEP_EXECUTION looks like this

  • STEP_NAME: partitionStep, JOB_EXECUTION_ID: 1, EXIT_CODE: FAILED
  • STEP_NAME: partitionStep, JOB_EXECUTION_ID: 2, EXIT_CODE: COMPLETED

Expected behavior
myStep should be executed on retry. After the retry the contents of BATCH_STEP_EXECUTION should look like this

  • STEP_NAME: partitionStep, JOB_EXECUTION_ID: 1, EXIT_CODE: FAILED
  • STEP_NAME: partitionStep, JOB_EXECUTION_ID: 2, EXIT_CODE: COMPLETED
  • STEP_NAME: myStep:partition-0, JOB_EXECUTION_ID: 2, EXIT_CODE: COMPLETED
  • STEP_NAME: myStep:partition-1, JOB_EXECUTION_ID: 2, EXIT_CODE: COMPLETED
  • ...

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 with the partitioned StepBuilder configuration and the custom Partitioner.partition() entry point, then reproduce the failure and retry using the Spring Batch 5.1.2 setup described. Inspect BATCH_STEP_EXECUTION after the retry; done means the partitioned myStep executions are created and completed when the first partitioning attempt failed.

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
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.