Skip to content

A platform for community discussion. Free, open, simple.

ActiveRecord in Rails 5.2 discards connection pools after fork.

Guo Xiang Tan805fd17b230a
diff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rb
index 6d2026db612..9c0e51c3d1b 100644
--- a/config/unicorn.conf.rb
+++ b/config/unicorn.conf.rb
@@ -205,10 +205,6 @@ before_fork do |server, worker|
end
- RailsMultisite::ConnectionManagement.each_connection do
- ActiveRecord::Base.connection_pool.disconnect!
- end
-
$redis._client.disconnect
# Throttle the master from forking too quickly by sleeping. Due
diff --git a/lib/discourse.rb b/lib/discourse.rb
index d36f46c2b26..4f8ae8e7246 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -436,8 +436,6 @@ module Discourse
# in a bad state
def self.after_fork
# note: all this reconnecting may no longer be needed per https://github.com/redis/redis-rb/pull/414
- current_db = RailsMultisite::ConnectionManagement.current_db
- RailsMultisite::ConnectionManagement.establish_connection(db: current_db)
MessageBus.after_fork
SiteSetting.after_fork
$redis._client.reconnect