mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Catch all Redis errors and check for NOREPLICAS, fixes #4495
This commit is contained in:
parent
66bb4369fb
commit
267b4cc601
1 changed files with 3 additions and 2 deletions
|
@ -96,10 +96,11 @@ module Sidekiq
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue