Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Retry all exceptions.

  • Loading branch information...
commit f761c674a4bd935a3993adbb8e9e9ef39eea5540 1 parent 0a58b7f
@jonhyman jonhyman authored
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/sidekiq/processor.rb
View
13 lib/sidekiq/processor.rb
@@ -93,7 +93,7 @@ def identity
def stats(worker, msg, queue)
# Do not conflate errors from the job with errors caused by updating stats so calling code can react appropriately
- retry_and_suppress_redis_timeouts do
+ retry_and_suppress_exceptions do
redis do |conn|
conn.multi do
conn.sadd('workers', identity)
@@ -107,7 +107,7 @@ def stats(worker, msg, queue)
begin
yield
rescue Exception
- retry_and_suppress_redis_timeouts do
+ retry_and_suppress_exceptions do
redis do |conn|
failed = "stat:failed:#{Time.now.utc.to_date}"
result = conn.multi do
@@ -119,7 +119,7 @@ def stats(worker, msg, queue)
end
raise
ensure
- retry_and_suppress_redis_timeouts do
+ retry_and_suppress_exceptions do
redis do |conn|
processed = "stat:processed:#{Time.now.utc.to_date}"
result = conn.multi do
@@ -147,19 +147,18 @@ def cloned(ary)
# If there is a Redis::TimeoutError, the block passed to this method will be retried up to max_retries times.
# All exceptions will be swallowed and logged.
- def retry_and_suppress_redis_timeouts(max_retries = 2)
+ def retry_and_suppress_exceptions(max_retries = 2)
retry_count = 0
begin
yield
- rescue Redis::TimeoutError
+ rescue StandardError
@mperham Owner
mperham added a note

StandardError is superfluous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
retry_count += 1
if retry_count <= max_retries
+ Sidekiq.logger.debug {"Suppressing and retrying error: #{e.inspect}"}
retry
else
Sidekiq.logger.info {"Exhausted #{max_retries} retries due to Redis timeouts: #{e.inspect}"}
end
- rescue StandardError => e
- Sidekiq.logger.info {"Suppressing error #{e.inspect}"}
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.