log exception on redis failure recovery

test plan: turn redis caching on but don't have redis running, hit a
page, verify the generated error

Change-Id: Iddd525ed468abdcf0cce2dba9becc65e2d5aaa84
Reviewed-on: https://gerrit.instructure.com/9309
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Brian Palmer 2012-03-08 14:31:05 -07:00
parent acf8fa7d4f
commit 2211a8effa
1 changed files with 9 additions and 3 deletions

View File

@ -38,15 +38,21 @@ module Canvas::Redis
def self.handle_redis_failure(failure_retval)
return failure_retval if redis_failure?
yield
rescue Errno::ECONNREFUSED, Timeout::Error, Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EBADF, Errno::EINVAL
rescue Errno::ECONNREFUSED, Timeout::Error, Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EBADF, Errno::EINVAL => e
ErrorReport.log_exception(:redis, e)
Rails.logger.error "Failure handling redis command: #{e.inspect}"
@last_redis_failure = Time.now
failure_retval
rescue Errno::EAGAIN
rescue Errno::EAGAIN => e
ErrorReport.log_exception(:redis, e)
Rails.logger.error "Redis EAGAIN failure, trying again: #{e.inspect}"
# typically this means that redis closed the connection as idle,
# and trying again will succeed
begin
yield
rescue Errno::EAGAIN
rescue Errno::EAGAIN => e
ErrorReport.log_exception(:redis, e)
Rails.logger.error "Failure handling redis command: #{e.inspect}"
failure_retval
end
end