在Sidekiq中访问和删除死亡工作

时间:2015-07-14 13:07:18

标签: ruby-on-rails redis sidekiq fuseki

我在生产中的Docker容器中运行Sidekiq,无法访问Web UI。 Sidekiq工作人员似乎失败了,我需要检查他们是否确实失败了并删除或重试它们。

我在这里看到的并不是百分之百,但是使用workers = Sidekiq::Workers.new收集了工作人员,我在rails控制台中得到了这个结果,这让我相信我有一些死的工作:

workers.each { |process_id, thread_id, work| puts "Worker #{work}\n\n" }

Worker {"queue"=>"default", "payload"=>{"retry"=>1, "queue"=>"default", "class"=>"PeopleWorker", "args"=>["<arg-1>", "55800c0161616600b5000000"], "jid"=>"08126d4162242a26825ce2d3", "enqueued_at"=>1436800316.1181111, "error_message"=>"Error 503: The query timed out", "failed_at"=>1436816149.1032495, "retry_count"=>0}, "run_at"=>1436870942}

Worker {"queue"=>"default", "payload"=>{"retry"=>1, "queue"=>"default", "class"=>"PeopleWorker", "args"=>["<arg-1>", "55800c0161616600b5000000"], "jid"=>"16a68d843116702daad847d6", "enqueued_at"=>1436800316.2001767, "error_message"=>"Error 503: The query timed out", "failed_at"=>1436816221.2766316, "retry_count"=>0}, "run_at"=>1436874457}

Worker {"queue"=>"default", "payload"=>{"retry"=>1, "queue"=>"default", "class"=>"PeopleWorker", "args"=>["<arg-1>", "55800c0161616600b5000000"], "jid"=>"999ed8c1bb43192fa9a5c8b1", "enqueued_at"=>1436800312.3595853, "error_message"=>"Error 503: The query timed out", "failed_at"=>1436816142.493408, "retry_count"=>0}, "run_at"=>1436868587}

Worker {"queue"=>"default", "payload"=>{"retry"=>1, "queue"=>"default", "class"=>"PeopleWorker", "args"=>["<arg-1>", "55800c0161616600b5000000"], "jid"=>"91d2ece3dd75dd8a4c95baed", "enqueued_at"=>1436800316.4514835, "error_message"=>"Error 503: The query timed out", "failed_at"=>1436817504.064808, "retry_count"=>0}, "run_at"=>1436875742}

Worker {"queue"=>"default", "payload"=>{"retry"=>1, "queue"=>"default", "class"=>"PeopleWorker", "args"=>["<arg-1>", "55800c0161616600b5000000"], "jid"=>"af620ff8406c126f8f2df89c", "enqueued_at"=>1436800315.562301, "error_message"=>"Error 503: The query timed out", "failed_at"=>1436816221.7349763, "retry_count"=>0}, "run_at"=>1436872039}

Worker {"queue"=>"default", "payload"=>{"retry"=>1, "queue"=>"default", "class"=>"PeopleWorker", "args"=>["<arg-1>", "55800c0161616600b5000000"], "jid"=>"79601ece1f09a7721881bb0b", "enqueued_at"=>1436800316.3225756, "error_message"=>"Error 500: GC overhead limit exceeded", "error_class"=>"Tripod::Errors::BadSparqlRequest", "failed_at"=>1436817517.111997, "retry_count"=>0}, "run_at"=>1436876319}

=> ["1cc9c3e7af3e:104", "1cc9c3e7af3e:117", "1cc9c3e7af3e:130", "1cc9c3e7af3e:150", "1cc9c3e7af3e:164", "1cc9c3e7af3e:191", "1cc9c3e7af3e:210", "1cc9c3e7af3e:224", "1cc9c3e7af3e:250", "1cc9c3e7af3e:263", "1cc9c3e7af3e:290", "1cc9c3e7af3e:311", "1cc9c3e7af3e:323", "1cc9c3e7af3e:350", "1cc9c3e7af3e:91"]

根据htop,目前有15个Sidekiq流程正在运行,因此对于这些结果究竟发生了什么感到好奇。

  1. 我的理解是,在执行过程中遇到异常时,这些作业是否在死队列中?
  2. 既然如此,我应该强制重试这些工作,还是应该删除?我没有理由认为他们会第二次失败。

2 个答案:

答案 0 :(得分:3)

请仔细阅读Sidekiq API,包括Sidekiq::RetrySetSidekiq::DeadSet

https://github.com/mperham/sidekiq/wiki/API#retries

遇到异常的作业会进入RetrySet,因此可以自动重试。

答案 1 :(得分:0)

请使用此命令清除“死”作业统计信息

Sidekiq::DeadSet.new.clear