Quick revision
The short answer
I would require every settlement job to be restartable from its last commit and idempotent when re-run in full, with the business date as an identifying parameter so each day is one JobInstance with its full execution history. Outputs must carry run identifiers and be reproducible from kept input files with checksums, runbooks must define when to restart versus re-run, who may do it and how it is recorded, and CI must prove restart behaviour by injecting failures in the middle of a step.
What to remember
In this answer, we turned a regulatory requirement into batch standards. Every settlement job is restartable from its last commit and idempotent when re-run in full, the business date is an identifying parameter so each day is one JobInstance with full history, outputs carry run identifiers and are reproducible from stored inputs with checksums, runbooks separate routine restarts from approved re-runs and record both, and CI proves restart behaviour by injecting failures in the middle of steps.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would require every settlement job to be restartable from its last commit and idempotent when re-run in full, with the business date as an identifying parameter so each day is one JobInstance with its full execution history. Outputs must carry run identifiers and be reproducible from kept input files with checksums, runbooks must define when to restart versus re-run, who may do it and how it is recorded, and CI must prove restart behaviour by injecting failures in the middle of a step.
Why this question is asked
When a regulator says jobs must be safely re-runnable and auditable, it is asking two questions: if something goes wrong, can you produce the correct result again without making things worse, and can you show exactly what was run, when, by whom and on what input. Across 20 teams, each with its own habits, the answer has to be a standard that is simple to follow and easy to check. Interviewers ask this to see whether we can turn a compliance requirement into concrete engineering rules. In this answer, we will separate restart from re-run, then go through the requirements for restartability and idempotency, job identity, reproducible outputs, runbooks, and automated tests.
1Restart Versus Re-Run
Two words are often mixed up, and the standard must define them. A restart continues a failed or stopped run of the same JobInstance: Spring Batch creates a new JobExecution, skips completed steps, and resumes the failed step from the state saved at its last commit. A re-run processes a business date again from the start, usually because the input was wrong or the logic had a bug, and in Spring Batch it is a new JobInstance with an extra identifying parameter, such as rerun=1.
Restart is routine recovery and should be possible for any operator on call. A re-run changes settled results, so it is a controlled business event with an approval and a record. Most of the standard follows from treating them differently.
| Aspect | Restart | Re-run |
|---|---|---|
| Spring Batch identity | same JobInstance, new JobExecution | new JobInstance (rerun=1) |
| Starts from | last committed chunk of failed step | the beginning |
| Typical reason | outage, timeout, pod killed | bad input, logic bug, correction |
| Who may start it | on-call operator | approved by the business owner |
| Recorded as | execution history | change record plus execution history |
2Restartable and Idempotent by Design
Every job must be restartable from its last commit. That means readers that save their position, chunk sizes that keep the work lost on failure small, and no steps marked to re-run when already complete unless they are explicitly harmless setup steps. Every job must also be idempotent when re-run in full: running it twice for the same day must give the same final state as running it once.
The usual techniques are simple and should be in the standard's template. Writes are upserts keyed on business ids, or the job first deletes or marks as superseded its own previous output for that date and run. External effects go through an outbox with idempotency keys, so a re-run does not send payments twice. Outputs to files are written to a temporary name and renamed at the end, so a half-written file is never published.
3One JobInstance per Business Date
The identifying parameters of every settlement job must include the business date. Then each day maps to exactly one JobInstance, and the job repository holds its full history: every failed execution, every restart, their start and end times, statuses and step counts. Spring Batch also refuses to run a completed date again by accident, which is exactly the protection a regulator wants.
Non-identifying parameters, such as who launched the job or a trace id, are recorded with each execution without changing its identity. A re-run uses an additional identifying parameter, so it appears as a separate, visible instance rather than silently replacing the first.
4Reproducible and Auditable Outputs
An auditor will ask which input produced a given output. So every output, whether rows or files, carries the run identifier that produced it, such as the JobExecution id, and the input files are kept with their checksums, for example SHA-256, for the retention period. The job records the input checksum in its ExecutionContext and in an audit table at the start of the run.
- Receive input filestore it unchanged, record SHA-256
- Launch job with business date
JobInstancefor 2026-11-03 - Write outputs tagged with run idrows and files carry execution 7002
- Record summarycounts, totals, input checksum, operator
- Auditor asks: same result again?re-run from stored input, compare totals
5 steps in order. Play them, or step through them one at a time.
Reproducibility then means we can take the stored input, the same version of the code, recorded through the build version in the execution context, and reference data as of that date, and produce the same totals. Reference data is the part teams usually forget, so the standard requires either versioned reference data or a snapshot taken at the start of the run.
5Runbooks: Who Restarts, Who Re-Runs, and How It Is Recorded
Each settlement job has a runbook that defines, in plain steps, how to check whether a restart is safe, how to restart, and how to request a re-run. Restarts can be done by on-call operators using the platform's tooling, and they are automatically recorded in the job repository. Re-runs need approval by the job's business owner and are recorded in the change system with the reason, the approver, and the new instance id. Manual edits to the job repository, such as marking an execution failed, are allowed only through a documented procedure and are recorded the same way.
6Proving Restart Behaviour in CI
A requirement that is not tested will decay. So each job's build includes restart tests: run the job against test data, inject a failure in the middle of a step, for example by making the writer throw on a chosen item, restart the same instance, and assert that the final output equals the output of a clean run, with no duplicates and no gaps. A second test runs a full re-run for the same date and asserts the same final state. These tests catch the common regressions, such as a reader wrapped without being registered as a stream, before they reach production.
7Follow-up questions
How do you enforce this across 20 teams?
We publish the standard with a template project that already contains the patterns and the restart tests, and we make passing the restart tests a condition for scheduling a settlement job on the platform. A quarterly report shows each team's compliance, and gaps are tracked like any other audit finding.
Does idempotency conflict with keeping history?
No, if we separate them. The current settlement table holds the latest correct result per date, replaced on re-run, while an append-only audit table keeps each run's summary and run id. Auditors see every run; downstream consumers see one correct answer.
What if a job sends files to an external party?
The file name includes the business date and run id, the sending is a separate step with its own record of what was sent, and a re-run produces a new, clearly versioned file with a notice to the recipient, rather than silently overwriting a file they may already have processed.
8Conclusion
In this answer, we turned a regulatory requirement into batch standards. Every settlement job is restartable from its last commit and idempotent when re-run in full, the business date is an identifying parameter so each day is one JobInstance with full history, outputs carry run identifiers and are reproducible from stored inputs with checksums, runbooks separate routine restarts from approved re-runs and record both, and CI proves restart behaviour by injecting failures in the middle of steps.
Open with
I would start by defining two terms, because the rules differ. A restart continues the same JobInstance after a failure, from the last commit; a re-run processes a business date again from scratch as a new instance.
Then, if they want more
Then the requirements. Every job must be restartable, with readers that save their state and no unsafe re-run steps, and idempotent in full, typically with upserts keyed on business ids and an outbox with idempotency keys for anything external.
The business date must be an identifying parameter, so each day is exactly one JobInstance and the job repository holds its full history of executions; that also stops accidental double runs.
Outputs must carry the run identifier, and we keep the input files with checksums, the code version and the reference data as of that date, so we can reproduce the result and show where every number came from.
Each job has a runbook saying how to check that a restart is safe, that on-call can restart, and that a re-run needs the business owner's approval and is recorded in the change system with a reason.
Finally, every job has automated restart tests in CI that inject a failure in the middle of a step, restart, and assert the result equals a clean run. Passing those tests is a condition for scheduling a settlement job.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Batch reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A regulator requires that your end-of-day settlement jobs can be safely re-run and their...": https://scrivio-interview-library.netlify.app/spring-boot/spring-batch/3e9aed6599/