From a4e6662833379908d728d803118e6860c494a91e Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 6 Jun 2018 14:45:05 +0800 Subject: [PATCH] FIX: Disconnects all connections in the pool before forking. * We were leaking connections as a result. Connections opened before the fork were never closed. --- config/unicorn.conf.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rb index 01c800b1986..3faf9f584ba 100644 --- a/config/unicorn.conf.rb +++ b/config/unicorn.conf.rb @@ -210,7 +210,10 @@ before_fork do |server, worker| end - ActiveRecord::Base.connection.disconnect! + RailsMultisite::ConnectionManagement.each_connection do + ActiveRecord::Base.connection_pool.disconnect! + end + $redis._client.disconnect # Throttle the master from forking too quickly by sleeping. Due