ruby-on-rails 如何强制重试滞留在重试队列中的Sidekiq作业?

dgtucam1  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(109)

我有很多作业堵塞在Sidekiq的重试队列中,延迟很高。由于某种原因,它们没有工作,我无法找到一种方法直接从重试队列本身调度这些作业的重试。
我该怎么做呢,基本上是强制重试所有这些?

dm7nw8vv

dm7nw8vv1#

似乎没有办法直接做到这一点。重试次数耗尽的重试作业最终应该转到DeadSet。首先收集重试作业及其参数:

require 'sidekiq/api'
jobs = Sidekiq::Queue.new("retries").map { |j| [j.klass, j.args] }
# => e.g.:
#  ["MyWorker", [125396, "some_arg"]],
#  ["MyWorker", [125394, "some_arg"]],
#  ["MyWorker", [125395, "some_arg"]],
#  ["MyWorker", [98761, "another_arg"]],
#  ["MyWorker", [98760, "another_arg"]],
#  ["MyWorker", [41624, "another_arg"]],
#  ["MyWorker", [41623, "another_arg"]],
#  ["MyWorker", [32164, "another_arg"]],
#  ["MyWorker", [32167, "some_arg"]],
#  ["MyWorker", [32165, "another_arg"]],
#  ["MyWorker", [31870, "some_arg"]],
#  ["MyWorker", [31871, "some_arg"]]]

字符串
现在,为每个作业安排立即重试:

jobs.each do |job|
  klass = job[0].constantize
  args = job[1]
  klass.perform_async(*args)
end


最后,我们清除重试队列:

Sidekiq::Queue.new("retries").clear

相关问题