Restarting a Spring batch job after app server fai

2019-09-21 16:12发布

问题:

When spring batch DB failure happens or server is shut down, a spring batch job which was running at that time will be in a unknown started state.

In spring batch admin, we will not see an option to restart the job. Hence we are not able to resume the job. How to restart the job from last successful commit?

The old discussions suggest that it had to be dealt manually by updating tables. I was manually able to update end time, status in batch step execution and batch job execution tables. Is it really the best option? It may not be practical to do that manually in a prod region.

回答1:

As mentioned in the Aborting a Job section of the reference documentation, when a server failure happens, the job repository has no way to know that the process running the job died. Hence a manual intervention is required.

How to restart the job from last successful commit?

Change the status of the job to FAILED and restart the job instance, it should continue from where it left off.