Commit 83e00716 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'fix_reloading_database_load_balance_connection' into 'master'

Reconfigure DB load balancing connection on code reload

See merge request gitlab-org/gitlab!84528
parents 4233aea3 b617e904
......@@ -2,6 +2,15 @@
Gitlab::Application.configure do |config|
config.middleware.use(Gitlab::Database::LoadBalancing::RackMiddleware)
# We need re-rerun the setup when code reloads in development
config.reloader.to_prepare do
if Rails.env.development? || Rails.env.test?
Gitlab::Database::LoadBalancing.base_models.each do |model|
Gitlab::Database::LoadBalancing::Setup.new(model).setup
end
end
end
end
Gitlab::Database::LoadBalancing.base_models.each do |model|
......@@ -14,6 +23,12 @@ Gitlab::Database::LoadBalancing.base_models.each do |model|
# information.
Gitlab::Database::LoadBalancing::Setup.new(model).setup
Rails.application.reloader.to_prepare do
if Rails.env.development?
Gitlab::Database::LoadBalancing::Setup.new(model).setup
end
end
# Database queries may be run before we fork, so we must set up the load
# balancer as early as possible. When we do fork, we need to make sure all the
# hosts are disconnected.
......
......@@ -17,6 +17,12 @@ module Gitlab
configure_connection
setup_connection_proxy
setup_service_discovery
::Gitlab::Database::LoadBalancing::Logger.debug(
event: :setup,
model: model.name,
start_service_discovery: @start_service_discovery
)
end
def configure_connection
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment