From 267b4cc601460f23d127a336fcf86f5be44ccce5 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Fri, 19 Jun 2020 12:10:27 -0700 Subject: [PATCH] Catch all Redis errors and check for NOREPLICAS, fixes #4495 --- lib/sidekiq.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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