mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
More intelligent redis error handling for job fetch
This commit is contained in:
parent
0fb1cbff38
commit
b04f7ac033
2 changed files with 12 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
|||
2.11.3
|
||||
-----------
|
||||
|
||||
- Better handling for Redis downtime when fetching jobs, don't print
|
||||
exceptions every second and print success message when Redis is back.
|
||||
- Fix unclean shutdown leading to duplicate jobs [#897]
|
||||
- Add Korean locale [#890]
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ module Sidekiq
|
|||
TIMEOUT = 1
|
||||
|
||||
def initialize(mgr, options)
|
||||
@down = nil
|
||||
@mgr = mgr
|
||||
@strategy = Fetcher.strategy.new(options)
|
||||
end
|
||||
|
@ -31,6 +32,8 @@ module Sidekiq
|
|||
|
||||
begin
|
||||
work = @strategy.retrieve_work
|
||||
::Sidekiq.logger.info("Redis is online, #{Time.now.to_f - @down.to_f} sec downtime") if @down
|
||||
@down = nil
|
||||
|
||||
if work
|
||||
@mgr.async.assign(work)
|
||||
|
@ -38,8 +41,13 @@ module Sidekiq
|
|||
after(0) { fetch }
|
||||
end
|
||||
rescue => ex
|
||||
logger.error("Error fetching message: #{ex}")
|
||||
logger.error(ex.backtrace.first)
|
||||
if !@down
|
||||
logger.error("Error fetching message: #{ex}")
|
||||
ex.backtrace.each do |bt|
|
||||
logger.error(bt)
|
||||
end
|
||||
end
|
||||
@down ||= Time.now
|
||||
sleep(TIMEOUT)
|
||||
after(0) { fetch }
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue