Announcement Announcement Module
No announcement yet.
Stopping a job: delay between 'STOPPING' and 'STOPPED' Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stopping a job: delay between 'STOPPING' and 'STOPPED'

    The bottom line: I need the job to be stopped quickly (not just the steps), so, jobParameters)
    does not block for so long.

    And now the details:

    I have a simple job set up:
    HTML Code:
    <job id="myJob" restartable="false"
            <step id="myStep">
                    <chunk reader="myReader"
    I launch the job inside a container:
    class AbstractJob{
    public Status run(...){
    this.jobParameters = jobParamsBuilder.toJobParameters();
    JobExecution jobExecution =, jobParameters);
    BatchStatus batchStatus = jobExecution.getStatus();
    if (batchStatus == BatchStatus.COMPLETED) ...
    public void abort(){
    JobOperator jobOperator = KBeansProvider.getBean("jobOperator");
    JobRepository jobRepository = KBeansProvider.getBean("dbJobRepository");
    JobExecution jobExecution = jobRepository.getLastJobExecution(this.jobBeanId, this.jobParameters);
    try {
    The method blocks, as I run in synced mode.
    Now, when I abort, I expect the call to return in a reasonable time, as the system is in idle state besides the job.
    The step is indeed stopped, as can be seen in the log:

    2012-02-12 18:36:14,649 INFO [] - <Parent JobExecution is stopped, so passing message on to StepExecution>
    2012-02-12 18:36:14,653 INFO [org.springframework.batch.core.step.ThreadStepInterruptionPolicy] - <Step interrupted through StepExecution>
    2012-02-12 18:36:14,656 ERROR [org.springframework.batch.core.step.AbstractStep] - <Encountered an error executing the step>
    org.springframework.batch.core.JobInterruptedException: Job interrupted status detected.
    	at org.springframework.batch.core.step.ThreadStepInterruptionPolicy.checkInterrupted(
    	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(
    The batch_step_execution status is set to stopped in a matter of half a minute or so.
    The problem is, the job itself is "stuck" in'STOPPING' mode.
    Sometimes it gets stopped - but only after an unreasonable time, about 10 minutes, and sometimes it just stays in 'STOPPING' mode.

    I also tried calling stop on the JobExecution itself, but it didn't solve it.

    Last edited by Yuval Rikover; Feb 19th, 2012, 10:52 AM.

  • #2
    I have a same problem.
    Have you already solved?


    • #3
      When asking a job to stop, you are doing just that...asking. There is no guarantee within the framework that processing will end in any particular time frame or at all (depending on your implementation of various artifacts). When the call to stop a job is received, the job is immediately flagged as STOPPING. It is not until all steps processing have stopped (which will check for that flag at different times based on your configuration) that the job is flagged as STOPPED. Without seeing your job configuration, there isn't much insight I can provide into why the gap between those two states is occurring.