Dally
Dally

Reputation: 1427

How to retry all failed jobs from Redis queue in Laravel Horizon

How can you retry all failed jobs in Laravel Horizon? There appears to be no "Retry All" button and the artisan command doesn't work as the failed jobs aren't stored in a table.

Upvotes: 4

Views: 11887

Answers (2)

kjones
kjones

Reputation: 1423

The queue:retry command accepts all in place of an individual job ID:

php artisan queue:retry all

This will push all of the failed jobs back onto your redis queue for retry:

The failed job [44] has been pushed back onto the queue!
The failed job [43] has been pushed back onto the queue!
...

If you didn't create the failed logs table according to the installation guide with:

php artisan queue:failed-table
php artisan migrate

Then you may be up a creek. Maybe try interacting with redis manually and trying to access the list of failed jobs directly (assuming the failed jobs entries haven't been wiped - looks like they default to persisting in redis for a week, based on the config settings in config/horizon.php).

Upvotes: 6

Kenny Horna
Kenny Horna

Reputation: 14241

as the failed jobs aren't stored in a table

Actually, you should create that table. From the Laravel Horizon documentation:

You should also create the failed_jobs table which Laravel will use to store any failed queue jobs:

php artisan queue:failed-table

php artisan migrate

Then, to retry failed jobs:

Retrying Failed Jobs

To view all of your failed jobs that have been inserted into your failed_jobs database table, you may use the queue:failed Artisan command:

php artisan queue:failed

The queue:failed command will list the job ID, connection, queue, and failure time. The job ID may be used to retry the failed job. For instance, to retry a failed job that has an ID of 5, issue the following command:

php artisan queue:retry 5

Upvotes: 3

Related Questions