The system health check (Self-Hosted v5, latest version, Mac Client APP) shows a Red triangle in the Queue section with 634 pending jobs and 8 failed jobs. Clicking on “View Last Queue Error” points to SMTP timeout error: (Illuminate\Queue\TimeoutExceededException: App\Listeners\Invoice\InvoiceEmailedNotification has timed out in /public_html/vendor/laravel/framework/src/Illuminate/Queue/TimeoutExceededException.php:15)
How do I track the pending jobs, they do not seem to go down automatically?
I am running the queue cronjob every minute as recommended: * * * * * php8.2 /public_html/artisan schedule:run >> /dev/null 2>&1
I also ran the queue by hand like below: php8.2 artisan schedule:run
and it runs without any errors.
How do I track this? When will these errors disappear?
Since the queue has been enabled you need to add the queue:work cron process the jobs.
Note: you may want to clear the jobs otherwise once it’s fixed many invoices will be processed. I believe you can use this command: php artisan queue:clear
How do I know the queue is enabled? ( I do see the .env variable defined as QUEUE_CONNECTION=database. Is that it?)
Your answer gave me a hint to check the queue related artisan commands:
queue
queue:clear Delete all of the jobs from the specified queue
queue:failed List all of the failed queue jobs
queue:flush Flush all of the failed queue jobs
queue:forget Delete a failed queue job
queue:listen Listen to a given queue
queue:monitor Monitor the size of the specified queues
queue:prune-batches Prune stale entries from the batches database
queue:prune-failed Prune stale entries from the failed jobs table
queue:restart Restart queue worker daemons after their current job
queue:retry Retry a failed queue job
queue:retry-batch Retry the failed jobs for a batch
queue:work Start processing jobs on the queue as a daemon
php8.2 artisan queue:failed lists the 8 failed jobs:
I ran php8.2 artisan queue:flush to flush the old failed jobs and now it doesn’t list any failed jobs.
php8.2 artisan queue:work still took a good 4 minutes and 46 seconds and it did not clear any of the pending jobs (still 634!), so running it every 5 minutes seems dangerous?
So should both php artisan schedule:run and php artisan queue:work be run in cron (once a minute and once every 5 minutes)?
Correct, setting QUEUE_CONNECTION to database means the database is used to queue the jobs. You can set it to sync to disable the queue.
I’m not sure you’ll want all of those jobs processed. If you can’t use the command line you may want to manually empty the jobs table (after taking a backup of the database).
You can use supervisor instead of the cron but it’s a bit more complicated to setup.
I think the documentation that you linked talks about supervisor setup.
I also realized that passing --stop-when-empty makes it exit in 4-5 seconds. So I think that’s what I will use in cron.
However I am still confused about the 634 pending jobs and the Yellow triangle in the health check. Are these jobs scheduled to run in future? Any way to list them? If this is normal circumstance, then why the Yellow triangle in Health check with 634 Pending jobs?
My guess is you enabled the queue a while ago but didn’t realize it wasn’t working. We recently added more info to the health check which is why you’re only seeing the error now.
You would need to view the jobs table in the database to see what’s pending.