Hi everybody,
I got a strange issue:
I am going to do some work on a video using long running jobs.
Some tasks require multiple steps, so in this case, I am using a chain of jobs like this:
- UploadVideoToStorageJob::class
- NormalizeVideo::class
- OptimizeVideo::class
Well - this works fine, if I am running this chain for one video.
Laravel horizon shows something like:
UploadVideoToStorageJob RUNNING
UploadVideoToStorageJob RUNNING
UploadVideoToStorageJob DONE
UploadVideoToStorageJob DONE
NomalizeVideo RUNNING
NomalizeVideo RUNNING
NomalizeVideo DONE
NomalizeVideo DONE
OptimizeVideo RUNNING
OptimizeVideo RUNNING
OptimizeVideo FAILED
OptimizeVideo FAILED
OptimizeVideo RUNNING
OptimizeVideo RUNNING
OptimizeVideo DONE
Well. That's too bad. There's only one OptimizeVideo DONE in the list.
Checking out the horizon dashboard, I can see that this job is pending and actually there is no work happening. How do I know? Well, the job spawns a docker container and all the time the job is pending, there is no container running at all.
After waiting for 20 minutes, the job will succeed.
I was wondering about that:
In the queue.php config, there is a retry_after value set, which is just a little higher than 20min:
'retry_after' => 1300,
This should mean that the job got picked up again. But I cannot explain, why it got stuck in the first place while it does nothing. After failing, the job is just waiting.
Edit
What I found out is that the docker-job itself doesn't really has to do something with this.
If two jobs are being retried due to an error, they are not being run concurrently after the first failure.