mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Make sure Redis fallback don't fall into a permanent readonly state.
This commit is contained in:
parent
bfd0418f07
commit
02025207d5
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user