6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Laravel】failed_jobsに入ったジョブをリランさせるSQL

Last updated at Posted at 2020-02-04

Laravelでdatabaseキューを使っている場合、失敗したジョブはfailed_jobsテーブルに入ります。
リラン(再実行)したい場合は、再度jobsテーブルに入れてあげればキューワーカーが再実行してくれます。

INSERT INTO jobs (
     queue
    ,payload
    ,attempts
    ,reserved_at
    ,available_at
    ,created_at
) SELECT 
	 queue
	,payload
	,0
	,null
	,UNIX_TIMESTAMP(now())
	,UNIX_TIMESTAMP(now())
   FROM failed_jobs
  WHERE id = X
;

上記のようなSQLでfailed_jobsに入ったレコードをjobsに戻せます。


SQLを使わなくてもartisanコマンドを使えば同じことができます(@mindwoodさんありがとうございます)。

php artisan queue:retry {ID}
失敗ジョブをID指定で再実行

他にも

php artisan queue:failed
失敗ジョブの確認

php artisan queue:retry all
失敗ジョブをすべて再実行

php artisan queue:forget {ID}
失敗ジョブをID指定で削除

php artisan queue:flush
失敗ジョブをすべて削除

があります。

6
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?