我有很多作业堵塞了 Sidekiq 中的重试队列,并且延迟很高。由于某种原因,它们没有被处理,并且我无法找到一种方法来直接从重试队列本身安排这些作业的重试。
我将如何做到这一点,本质上是强制重试所有这些?
似乎没有办法直接做到这一点。重试次数耗尽的重试作业最终应转到
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