lib/kestrel/client.rb in kestrel-client-0.6.0 vs lib/kestrel/client.rb in kestrel-client-0.6.1

- old
+ new

@@ -20,10 +20,26 @@ :timeout => 0.25, :gets_per_server => 100, :get_timeout_ms => 10 }.freeze + # Exceptions which are connection failures we retry after + RECOVERABLE_ERRORS = [ + Memcached::ServerIsMarkedDead, + Memcached::ATimeoutOccurred, + Memcached::ConnectionBindFailure, + Memcached::ConnectionFailure, + Memcached::ConnectionSocketCreateFailure, + Memcached::Failure, + Memcached::MemoryAllocationFailure, + Memcached::ReadFailure, + Memcached::ServerError, + Memcached::SystemError, + Memcached::UnknownReadFailure, + Memcached::WriteFailure + ] + include StatsHelper include RetryHelper def initialize(*servers) @@ -113,10 +129,10 @@ commands = extract_queue_commands(opts) val = begin send(select_get_method(key), key + commands, raw) - rescue Memcached::ATimeoutOccurred, Memcached::ServerIsMarkedDead + rescue *RECOVERABLE_ERRORS # we can't tell the difference between a server being down # and an empty queue, so just return nil. our sticky server # logic should eliminate piling on down servers nil end