无法删除失败的作业(laravel 7)

问题描述 投票:0回答:1

我的 Redis 队列中有几千个失败的作业,每次启动 Horizon 时,它们都会重试并失败。我需要把它们全部除掉。

我尝试过

php artisan queue:flush
输出消息“所有失败的作业已成功删除!”

但他们都还在那里。

我注意到 Laravel 8 Horizion 文档,他们添加了

php artisan horizon:clear
,但我现在无法升级。我该怎么做才能删除所有内容?

laravel
1个回答
0
投票

唯一对我有用的解决方案是进入 Redis 并直接删除条目

使用 Docker 在 config/horizon.php 上找到 Horizon 队列的名称是什么

'prefix' => env(
        'HORIZON_PREFIX',
        Str::slug(env('APP_NAME', 'laravel'), '_') . '_horizon:'
    ),

假设在您的 .env 文件中 APP_NAME = BFT Dev,则 Redis 上失败队列的名称将是:

bft_dev_horizon:failed_jobs

进入redis-cli容器

# redis-cli
127.0.0.1:6379> AUTH password (only if you have a password)
OK
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> del bft_dev_horizon:failed_jobs:* bft_dev_horizon:failed_jobs
(integer) 1
127.0.0.1:6379>

在 Amazon Linux 2023 上 它使用 redis6-cli ,使用上面相同的代码,您将清理失败的作业

# redis6-cli
127.0.0.1:6379> AUTH password (only if you have a password)
OK
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> del bft_dev_horizon:failed_jobs:* bft_dev_horizon:failed_jobs
(integer) 1
127.0.0.1:6379>
© www.soinside.com 2019 - 2024. All rights reserved.