From 7406686f08217a86f3fd14795aa2770525a076c0 Mon Sep 17 00:00:00 2001 From: Nicholas Firth-McCoy Date: Tue, 20 Oct 2015 13:21:27 +1100 Subject: [PATCH] Rescue from Redis::BaseError in #ab_test Redis defines a number of different exception classes (see https://github.com/redis/redis-rb/blob/1bd43346cdf71ba69176612714616289a5a70ed4/lib/redis/errors.rb for details). When Redis raises an exception, we need to be able to have the db_failover configuration used, whether it's a failure to connect, a timeout, or an invalid command. We ran into this issue when our Redis instance ran out of memory. In that case (and most others), Split should be able to handle things gracefully. --- lib/split/helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/split/helper.rb b/lib/split/helper.rb index 8d45e2f4..b0e700c1 100644 --- a/lib/split/helper.rb +++ b/lib/split/helper.rb @@ -16,7 +16,7 @@ def ab_test(metric_descriptor, control = nil, *alternatives) else control_variable(experiment.control) end - rescue Errno::ECONNREFUSED, Redis::CannotConnectError, SocketError => e + rescue Errno::ECONNREFUSED, Redis::BaseError, SocketError => e raise(e) unless Split.configuration.db_failover Split.configuration.db_failover_on_db_error.call(e)