sidekiq_alive icon indicating copy to clipboard operation
sidekiq_alive copied to clipboard

Queue is not removed when sidekiq stops

Open arturictus opened this issue 6 years ago • 2 comments

Screenshot from 2019-10-07 15-36-45

arturictus avatar Oct 07 '19 13:10 arturictus

I am currently doing this daily to deal with this issue:

Sidekiq::Queue
  .all
  .select { |q| q.name =~ /^sidekiq_alive-/ }
  .select { |q| q.any? { |w| w.created_at < 1.day.ago } }
  .each(&:clear)

Obviously not ideal, but helps for the time being.

sunny avatar Aug 30 '20 21:08 sunny

This is the script I wrote to remove all sidekiq-alive queues that don't have a registered instance (zombie queues).

queues = Sidekiq::Queue.all

queues.each do |queue|
  next unless queue.name.starts_with? 'sidekiq_alive-'

  registered_queues = SidekiqAlive.registered_instances.map { |i| "sidekiq_alive-#{i.split('::')[1]}" }

  next if registered_queues.include? queue.name

  puts "Clearing queue #{queue.name}"
  queue.clear
end

Blayr avatar Sep 13 '21 17:09 Blayr