Announcement Announcement Module
No announcement yet.
How to restart a Job after a JVM Crash Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to restart a Job after a JVM Crash


    I'm trying to figure out how to restart a Job after a JVM Crash (While the job was running earlier).

    My test scenario-
    • I launch a job with a particular set of parameters (call to, jobParameters))
    • While the job is in the middle of execution, I kill the JVM
    • Next I try to fire the job again as I did in the first step (with the same set of parameters) but I get a JobExecutionAlreadyRunningException
    I guess- the way i'm restarting the job is probably not the right way. Can someone suggest the right way to get this done?


  • #2
    You need to manually set the endTime and status of the JobExecution in the repository before re-launching because there is no way to trap a process dying.


    • #3
      > there is no way to trap a process dying
      Isn't the existence of data implying "already running" job executions on startup is indication enough to the Batch that something serious failed and cleanup is required?


      • #4
        I don't think so because if the data say that something is running, there is no way to know that it is not (the data being generally managed by a different process than the job). You can inspect the lastUpdated fields in StepExecution and JobExecution and make a decision yourself through some manual process on whether the job actually died or not, but there is no reliable way to automate that decision.


        • #5
          Understood. Is the information to "make a decision yourself" and reset things available through the APIs (rather than resorting to SQL). This must be a common problem so there should be a common solution (decision-making aside). In our initial implementation there is only one JVM so it is clear that any such jobs must be reset at startup.


          • #6
            I usually find I get everything I need from Spring Batch Admin, which means that it comes from the JobExplorer or JobRepository in Spring Batch. If you find some specific examples that could be improved, please write them down and post them here or in JIRA.