mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Race-condition in fallback handlers (#8005)
Calling `verify_master` in multiple threads simultaneously would cause multiple threads to be spawned.
This commit is contained in:
parent
00b75b4f4e
commit
6924f1ab15
@ -32,7 +32,8 @@ class PostgreSQLFallbackHandler
|
||||
end
|
||||
|
||||
def verify_master
|
||||
synchronize { return if @thread && @thread.alive? }
|
||||
synchronize do
|
||||
return if @thread && @thread.alive?
|
||||
|
||||
@thread = Thread.new do
|
||||
while true do
|
||||
@ -46,6 +47,7 @@ class PostgreSQLFallbackHandler
|
||||
|
||||
@thread.abort_on_exception = true
|
||||
end
|
||||
end
|
||||
|
||||
def master_down?
|
||||
synchronize { @masters_down[namespace] }
|
||||
|
@ -23,7 +23,8 @@ class DiscourseRedis
|
||||
end
|
||||
|
||||
def verify_master
|
||||
synchronize { return if @thread && @thread.alive? }
|
||||
synchronize do
|
||||
return if @thread && @thread.alive?
|
||||
|
||||
@thread = Thread.new do
|
||||
loop do
|
||||
@ -38,6 +39,7 @@ class DiscourseRedis
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def initiate_fallback_to_master
|
||||
success = false
|
||||
|
Loading…
Reference in New Issue
Block a user