diff --git a/lib/resque/data_store.rb b/lib/resque/data_store.rb index a21f4ee7a..9b317a489 100644 --- a/lib/resque/data_store.rb +++ b/lib/resque/data_store.rb @@ -76,9 +76,10 @@ def identifier @redis.inspect end - # Force a reconnect to Redis. + # Force a reconnect to Redis without closing the connection in the parent + # process after a fork. def reconnect - @redis._client.reconnect + @redis._client.connect end # Returns an array of all known Resque keys in Redis. Redis' KEYS operation diff --git a/test/worker_test.rb b/test/worker_test.rb index 0f4516e5f..5f5d5a485 100644 --- a/test/worker_test.rb +++ b/test/worker_test.rb @@ -1218,11 +1218,12 @@ def run_in_job(&block) new_connection = run_in_job do Resque.redis._client.connection.instance_variable_get("@sock").object_id end + assert Resque.redis._client.connected? refute_equal original_connection, new_connection end it "tries to reconnect three times before giving up and the failure does not unregister the parent" do - @worker.redis._client.stubs(:reconnect).raises(Redis::BaseConnectionError) + @worker.data_store.stubs(:reconnect).raises(Redis::BaseConnectionError) @worker.stubs(:sleep) Resque.logger = DummyLogger.new @@ -1236,7 +1237,7 @@ def run_in_job(&block) end it "tries to reconnect three times before giving up" do - @worker.redis._client.stubs(:reconnect).raises(Redis::BaseConnectionError) + @worker.data_store.stubs(:reconnect).raises(Redis::BaseConnectionError) @worker.stubs(:sleep) Resque.logger = DummyLogger.new