Only successful jobs seem to decrease job_batch.pending_jobs, leading to batches that remain "unfinished"#61835
Laravel Version
13.23.0
PHP Version
8.4.23
Database Driver & Version
sqlite
Description
- I am submitting a batch of jobs using
Bus::batch($jobs)->allowFailures()->finally(...)->dispatch(), onto a queue with a worker running - I have a job with
use Batchable, Queueable, SerializesModels, InteractsWithQueue;and the attribute #[Tries(1)] (and the associated import) (I have also tried settingpublic int $tries = 1;) - When all of the jobs are successful (i.e. throw no errors), then I see pending_jobs steadily decrease in the job_batches table, and once all jobs are processed, my finally method is called, and I eventually see the job_batches entry updated with a value for finished_at
- If I make all of the jobs fail (i.e. throw an exception), then I see failed_jobs and failed_job_ids increase, but pending_jobs remains unchanged throughout. Once all jobs have been processed, my finally method is called, but a value for finished_at is never set on the job_batch and pending_jobs still equals total_jobs. I also see entries in the failed_jobs table for each job
- If I have a mixture of successful and failing jobs, then only the successful ones decrease pending_jobs. Once all jobs have been processed, my finally method is called, but a value for finished_at is never set on the job_batch
Steps To Reproduce
- Job class defined to only be tried once, and that throws an exception (RuntimeException in my case) in the handle() method