Skip to content

Commit

Permalink
Catch all Redis errors and check for NOREPLICAS, fixes #4495
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jun 19, 2020
1 parent 66bb436 commit 267b4cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/sidekiq.rb
Expand Up @@ -96,10 +96,11 @@ def self.redis
retryable = true
begin
yield conn
rescue Redis::CommandError => ex
rescue Redis::BaseError => ex
# 2550 Failover can cause the server to become a replica, need
# to disconnect and reopen the socket to get back to the primary.
if retryable && ex.message =~ /READONLY/
# 4495 Use the same logic if we have a "Not enough replicas" error from the primary
if retryable && ex.message =~ /READONLY|NOREPLICAS/
conn.disconnect!
retryable = false
retry
Expand Down

0 comments on commit 267b4cc

Please sign in to comment.