diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index 2f67d12d4..e61876760 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -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