Closed dim closed 10 years ago
Or you could keep a clone of your @sentinels_options
as @original_sentinels_options
and do:
def try_next_sentinel
sentinel_options = @sentinels_options.shift
if sentinel_options
# ...
else
@sentinels_options = @original_sentinel_options.clone
raise Redis::CannotConnectError
end
end
@dim I have fixed in HEAD code, please try and let me know if it works
Hmm, it works but I am a little concerned about the logic in the approach:
def try_next_sentinel
sentinel_options = @sentinels_options.shift
@sentinels_options.push sentinel_options
if sentinel_options
...
end
Because you are pushing the options straight back into the array, sentinel_options
can never be nil, so you can safely reduce the method down to:
def try_next_sentinel
sentinel_options = @sentinels_options.shift
@sentinels_options.push sentinel_options
@logger.debug "Trying next sentinel: #{sentinel_options[:host]}:#{sentinel_options[:port]}" if @logger && @logger.debug?
@current_sentinel = Redis.new sentinel_options
end
@dim thanks, I have update the code and released 1.4.1 version.
Hmm, sorry, we made a mistake while testing, seems like you should yank 1.4.1. Will send a patch request shortly.
In our staging setup, we have a single sentinel running. On the first redis timeout/disconnect, we start to receive continuous
Redis::CannotConnectError
errors. The client doesn't seem to reconnect an the the persist on every redis call until we restart the app.I think there is a problem with
try_next_sentinel
, as it shifts from the list of@sentinel_options
, never returning them back to the array. I didn't dive into the code, but shouldn't the method look something like this:Full backtrace: