How do I clear stuck/stale Resque workers?

后端 未结 15 757
你的背包
你的背包 2020-12-07 07:22

As you can see from the attached image, I\'ve got a couple of workers that seem to be stuck. Those processes shouldn\'t take longer than a couple of seconds.

相关标签:
15条回答
  • 2020-12-07 07:47

    None of these solutions worked for me, I would still see this in redis-web:

    0 out of 10 Workers Working
    

    Finally, this worked for me to clear all the workers:

    Resque.workers.each {|w| w.unregister_worker}
    
    0 讨论(0)
  • 2020-12-07 07:47

    Here's how you can purge them from Redis by hostname. This happens to me when I decommission a server and workers do not exit gracefully.

    Resque.workers.each { |w| w.unregister_worker if w.id.start_with?(hostname) }
    
    0 讨论(0)
  • 2020-12-07 07:49

    If you are using newer versions of Resque, you'll need to use the following command as the internal APIs have changed...

    Resque::WorkerRegistry.working.each {|work| Resque::WorkerRegistry.remove(work.id)}
    
    0 讨论(0)
  • 2020-12-07 07:50

    This avoids the problem as long as you have a resque version newer than 1.26.0:

    resque: env QUEUE=foo TERM_CHILD=1 bundle exec rake resque:work
    

    Keep in mind that it does not let the currently running job finish.

    0 讨论(0)
  • 2020-12-07 07:54

    I had a similar problem that Redis saved the DB to disk that included invalid (non running) workers. Each time Redis/resque was started they appeared.

    Fix this using:

    Resque::Worker.working.each {|w| w.done_working}
    Resque.redis.save # Save the DB to disk without ANY workers
    

    Make sure you restart Redis and your Resque workers.

    0 讨论(0)
  • 2020-12-07 07:55

    I ran into this issue and started down the path of implementing a lot of the suggestions here. However, I discovered the root cause that was creating this issue was that I was using the gem redis-rb 3.3.0. Downgrading to redis-rb 3.2.2 prevented these workers from getting stuck in the first place.

    0 讨论(0)
提交回复
热议问题