I fixed the multithreading issue with connection management a while back, remove mutex, it only slows down job processing
This commit is contained in:
parent
80fb20816c
commit
b9c4bf9870
1 changed files with 3 additions and 9 deletions
12
lib/jobs.rb
12
lib/jobs.rb
|
@ -22,10 +22,6 @@ module Jobs
|
||||||
self.new.perform(opts)
|
self.new.perform(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.mutex
|
|
||||||
@mutex ||= Mutex.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def execute(opts={})
|
def execute(opts={})
|
||||||
raise "Overwrite me!"
|
raise "Overwrite me!"
|
||||||
end
|
end
|
||||||
|
@ -57,11 +53,9 @@ module Jobs
|
||||||
|
|
||||||
dbs.each do |db|
|
dbs.each do |db|
|
||||||
begin
|
begin
|
||||||
Jobs::Base.mutex.synchronize do
|
RailsMultisite::ConnectionManagement.establish_connection(db: db)
|
||||||
RailsMultisite::ConnectionManagement.establish_connection(db: db)
|
I18n.locale = SiteSetting.default_locale
|
||||||
I18n.locale = SiteSetting.default_locale
|
execute(opts)
|
||||||
execute(opts)
|
|
||||||
end
|
|
||||||
ensure
|
ensure
|
||||||
ActiveRecord::Base.connection_handler.clear_active_connections!
|
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||||
end
|
end
|
||||||
|
|
Reference in a new issue