spring-batch icon indicating copy to clipboard operation
spring-batch copied to clipboard

BatchStatus#isRunning() is not consistent with JobExplorer#findRunningJobExecutions(String) or JobExecution#isRunning()

Open spring-projects-issues opened this issue 12 years ago • 2 comments

Alexis SOUMAGNE opened BATCH-2114 and commented

In STOPPING status should be considered as a "running" status. The endTime is null until job status is STOPPED. Which means that the job did not recieved interuption signal yet.

Simply the code should be :

public boolean isRunning() {
   return this == STARTING || this == STARTED || this == STOPPING;
}

Affects: 2.2.2

spring-projects-issues avatar Sep 24 '13 05:09 spring-projects-issues

Alexis SOUMAGNE commented

Up!

spring-projects-issues avatar Oct 07 '13 01:10 spring-projects-issues

I also encountered a problem related to this issue. That is, when launching multi jobs with same parameters in multi threads, there should be only one job can succeed, but actually, there would be more than one job can succeed.

I find it is caused by SimpleJobRepository#createJobExecution, this method uses JobExecution#isRunning(), but not BatchStatus#isRunning(). So the status STARTING is missing, since startTime of JobExecution will be set only when its status changes to STARTED.

for (JobExecution execution : executions) {
    if (execution.isRunning() || execution.isStopping()) {
        throw new JobExecutionAlreadyRunningException("A job execution for this job is already running: " + jobInstance);
    }
...

lcmarvin avatar May 10 '22 14:05 lcmarvin