FIX: Make sure Redis fallback don't fall into a permanent readonly state.

This commit is contained in:
Guo Xiang Tan 2016-11-23 11:29:28 +08:00
parent bfd0418f07
commit 02025207d5
2 changed files with 8 additions and 2 deletions

View File

@ -60,7 +60,7 @@ class DiscourseRedis
end
def running?
synchronize { @timer_task.running? }
@timer_task.running?
end
private
@ -92,7 +92,10 @@ class DiscourseRedis
end
def resolve
return @slave_options if !@fallback_handler.master
if !@fallback_handler.master
@fallback_handler.verify_master unless @fallback_handler.running?
return @slave_options
end
begin
options = @options.dup

View File

@ -60,11 +60,14 @@ describe DiscourseRedis do
Redis::Client.any_instance.expects(:call).raises(error).once
expect { connector.resolve }.to raise_error(error)
fallback_handler.instance_variable_get(:@timer_task).shutdown
expect(fallback_handler.running?).to eq(false)
config = connector.resolve
expect(config[:host]).to eq(slave_host)
expect(config[:port]).to eq(slave_port)
expect(fallback_handler.running?).to eq(true)
ensure
fallback_handler.master = true
end