如何删除所有排队的作业,因为这会导致错误? [英] How to remove all queued jobs because it's causing errors?

查看:85
本文介绍了如何删除所有排队的作业,因为这会导致错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站将电子邮件发送作业排队到jobs表中.我认为电子邮件服务器存在一些问题,它无法发送电子邮件,因此作业被卡在作业表中.现在也许有太多的工作,并且我收到此错误消息:

My website queues email sending jobs to the jobs table. I think the email server has some problem and it can't send emails so the jobs are stuck at the jobs table. Now maybe there are too many jobs, and I receive this error message:

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'attempts' at row 1 (SQL: update `jobs` set `reserved_at` = 1510263884, `attempts` = 256 where `id` = 342)' in /var/www/vhosts/parcgilley.com/httpdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php:647
#0 /var/www/vhosts/parcgilley.com/httpdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php(607): Illuminate\Database\Connection->runQueryCallback('update `jobs` s...', Array, Object(Closure))
#1 /var/www/vhosts/parcgilley.com/httpdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php(477): Illuminate\Database\Connection->run('update `jobs` s...', Array, Object(Closure))
#2 /var/www/vhosts/parcgilley.com/httpdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php(416): Illuminate\Database\Connection->affectingStatement('update `jobs` s...', Array)

所以我想知道如何刷新所有排队的作业以清除表?我无法访问数据库以删除表中的数据,因此是否有任何命令行可以这样做?我没有失败的队列表.

So I am wondering how do I flush all the queued jobs to clear the table? I can't access the database to remove the data in the table, so is there any command line to do so? I don't have a failed queue table.

推荐答案

假设您正在使用数据库驱动程序,则可以使用:

Assuming you are using database driver you can use:

DB::table('jobs')->delete();

删除所有作业.

另一件事是,您应该始终在设置尝试次数的情况下运行队列工作器:

The other thing is that you should always run queue worker with attempts set:

php artisan queue:work --tries=3

还请记住,每当更改应用程序代码时,都应重新启动工作程序:

Also remember that whenever you change your application code, you should restart your workers:

php artisan queue:restart

(我假设您使用主管,它将再次启动工作人员).

( I assume you use supervisor that will start workers again).

这篇关于如何删除所有排队的作业,因为这会导致错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆