Skip to content

Add API to mark a job execution as failed for restart #4876

Open
@fmbenhassine

Description

@fmbenhassine

This was initially discussed with @Nhoutain in #4831

Abrupt shutdowns of Spring Batch jobs leave the job execution in a running status at the job repository level as Spring Batch doesn't have a change to update the status correctly (see Aborting a Job). Restarting such failed jobs requires a manual database update as follows:

> update BATCH_JOB_EXECUTION set status = 'FAILED', END_TIME = 'non null value' where job_execution_id = X;
> update BATCH_STEP_EXECUTION set status = 'FAILED' where job_execution_id = X and step_name='failed step name';

There is already an API in the JobOperator to abandon a job execution, so it would be great to provide a new method to mark a job as failed to be able to restart it. The goal is to provide an API to mark a job as failed as opposed to asking users to manually execute SQL statements against the database. Providing an API is also necessary to support that feature consistently with other job repositories as well (thinking about No SQL stores for instances).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions