mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: in redis readonly raise an exception from DistributedMutex
If we detect redis is in readonly we can not correctly get a mutex raise an exception to notify caller When getting optimized images avoid the distributed mutex unless for some reason it is the first call and we need to generate a thumb In redis readonly no thumbnails will be generated
This commit is contained in:
@ -45,4 +45,29 @@ describe DistributedMutex do
|
||||
}.to raise_error(ThreadError)
|
||||
end
|
||||
|
||||
context "readonly redis" do
|
||||
before do
|
||||
$redis.slaveof "127.0.0.1", "99991"
|
||||
end
|
||||
|
||||
after do
|
||||
$redis.slaveof "no", "one"
|
||||
end
|
||||
|
||||
it "works even if redis is in readonly" do
|
||||
m = DistributedMutex.new("test_readonly")
|
||||
start = Time.now
|
||||
done = false
|
||||
|
||||
expect {
|
||||
m.synchronize do
|
||||
done = true
|
||||
end
|
||||
}.to raise_error(Discourse::ReadOnly)
|
||||
|
||||
expect(done).to eq(false)
|
||||
expect(Time.now - start).to be < (1.second)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user