diff --git a/lib/discourse.rb b/lib/discourse.rb index 01704e3d468..3f9235ae908 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -238,11 +238,12 @@ module Discourse # after fork, otherwise Discourse will be # in a bad state def self.after_fork + current_db = RailsMultisite::ConnectionManagement.current_db + RailsMultisite::ConnectionManagement.establish_connection(db: current_db) + MessageBus.after_fork SiteSetting.after_fork - ActiveRecord::Base.establish_connection $redis.client.reconnect Rails.cache.reconnect - MessageBus.after_fork # /!\ HACK /!\ force sidekiq to create a new connection to redis Sidekiq.instance_variable_set(:@redis, nil) end diff --git a/lib/export/exporter.rb b/lib/export/exporter.rb index aeec7419893..96bdaeeb67b 100644 --- a/lib/export/exporter.rb +++ b/lib/export/exporter.rb @@ -144,6 +144,7 @@ module Export pg_dump_running = true Thread.new do + RailsMultisite::ConnectionManagement::establish_connection(db: @current_db) while pg_dump_running message = logs.pop.strip log(message) unless message.blank?