From 99a3194a96fc36daa6f88b5afb6a0b16f6f55b54 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Wed, 14 Oct 2015 11:08:36 -0700 Subject: [PATCH] Make global stats processing gracefully handle errors --- lib/sidekiq/launcher.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/sidekiq/launcher.rb b/lib/sidekiq/launcher.rb index 559789e5..e8dfd1ab 100644 --- a/lib/sidekiq/launcher.rb +++ b/lib/sidekiq/launcher.rb @@ -71,10 +71,9 @@ module Sidekiq end def ❤(key, json) + fails = procd = 0 begin - fails = 0 Processor::FAILURE.update {|curr| fails = curr; 0 } - procd = 0 Processor::PROCESSED.update {|curr| procd = curr; 0 } workers_key = "#{key}:workers".freeze @@ -91,6 +90,7 @@ module Sidekiq end end end + fails = procd = 0 _, _, _, msg = Sidekiq.redis do |conn| conn.pipelined do @@ -111,6 +111,9 @@ module Sidekiq rescue => e # ignore all redis/network issues logger.error("heartbeat: #{e.message}") + # don't lose the counts if there was a network issue + PROCESSED.increment(procd) + FAILURE.increment(fails) end end