When a job fails with ModelNotFoundException, the job is not retried automatically considering --tries option set on worker and is added immediately to failed_jobs table.
You might argue that if a model does no longer exists, there is no point in retrying the job because it will fail for the same reason and I agree with that. But the reasons why a model can not be restored are multiple not only because is deleted.
But there are cases when retrying the job will make the job succeed. ie: a worker on a different server that the one from where it was dispatched, and which is listening to a mysql replica and the new record is not yet propagated.
Steps To Reproduce:
$model = Model::create([]);
$model->delete();
dispatch( new SampleJob($model));
php artisan queue:work --tries=3
I expect that SampleJob to be executed 3 times. Currently is executed only once.
Description:
When a job fails with
ModelNotFoundException
, the job is not retried automatically considering--tries
option set on worker and is added immediately tofailed_jobs
table.You might argue that if a model does no longer exists, there is no point in retrying the job because it will fail for the same reason and I agree with that. But the reasons why a model can not be restored are multiple not only because is deleted.
But there are cases when retrying the job will make the job succeed. ie: a worker on a different server that the one from where it was dispatched, and which is listening to a mysql replica and the new record is not yet propagated.
Steps To Reproduce:
I expect that SampleJob to be executed 3 times. Currently is executed only once.