diff --git a/Changes.md b/Changes.md index c6d53a17..2acfa959 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,8 @@ 3.2.2 ----------- +- Fix issue which could cause Sidekiq workers to disappear from the Busy + tab while still being active [#1884] - Add "Back to App" button in Web UI. You can set the button link via `Sidekiq::Web.app_url = 'http://www.mysite.com'` [#1875, seuros] - Add process tag (`-g tag`) to the Busy page so you can differentiate processes at a glance. [seuros, #1878] diff --git a/lib/sidekiq/launcher.rb b/lib/sidekiq/launcher.rb index 9beb1799..413b7bd9 100644 --- a/lib/sidekiq/launcher.rb +++ b/lib/sidekiq/launcher.rb @@ -71,14 +71,10 @@ module Sidekiq 'queues' => @options[:queues].uniq, 'labels' => Sidekiq.options[:labels], } - Sidekiq.redis do |conn| - conn.multi do - conn.sadd('processes', key) - conn.hset(key, 'info', Sidekiq.dump_json(data)) - conn.expire(key, 60) - end - end - manager.heartbeat(key, data) + # this data doesn't change so dump it to a string + # now so we don't need to dump it every heartbeat. + json = Sidekiq.dump_json(data) + manager.heartbeat(key, data, json) end def stop_heartbeat @@ -89,5 +85,6 @@ module Sidekiq end end end + end end diff --git a/lib/sidekiq/manager.rb b/lib/sidekiq/manager.rb index 5723c190..fea30822 100644 --- a/lib/sidekiq/manager.rb +++ b/lib/sidekiq/manager.rb @@ -132,26 +132,27 @@ module Sidekiq @threads[proxy_id] = thr end - def heartbeat(key, data) + def heartbeat(key, data, json) proctitle = ['sidekiq', Sidekiq::VERSION] proctitle << data['tag'] unless data['tag'].empty? proctitle << "[#{@busy.size} of #{data['concurrency']} busy]" proctitle << 'stopping' if stopped? $0 = proctitle.join(' ') - ❤(key) + ❤(key, json) after(5) do - heartbeat(key, data) + heartbeat(key, data, json) end end private - def ❤(key) + def ❤(key, json) begin - _, _, msg = Sidekiq.redis do |conn| + _, _, _, msg = Sidekiq.redis do |conn| conn.multi do - conn.hmset(key, 'busy', @busy.size, 'beat', Time.now.to_f) + conn.sadd('processes', key) + conn.hmset(key, 'info', json, 'busy', @busy.size, 'beat', Time.now.to_f) conn.expire(key, 60) conn.rpop("#{key}-signals") end