From 0b369a3c69f415a956c211124b2c1e9cfe505b9b Mon Sep 17 00:00:00 2001 From: Simon Tomlinson Date: Mon, 28 Jul 2025 17:01:14 -0500 Subject: [PATCH] Clean up connection pool in database_replica specs Fixes a connection pool leak in the :database_replica rspec decorator. Before this change, the connection pools created for each test were never disconnected, so each test wrapped in :database_replica would permenantly reserve 1 connection per database for the lifetime of the rspec session. --- spec/support/database_load_balancing.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/support/database_load_balancing.rb b/spec/support/database_load_balancing.rb index cc176dce3c944e..75432cd7002ea8 100644 --- a/spec/support/database_load_balancing.rb +++ b/spec/support/database_load_balancing.rb @@ -23,6 +23,10 @@ Gitlab::Database::LoadBalancing::SessionMap.clear_session redis_shared_state_cleanup! + Gitlab::Database::LoadBalancing.base_models.each do |model| + model.load_balancer.host_list.hosts.each(&:force_disconnect!) + end + old_proxies.each do |model, proxy| model.load_balancer, model.connection, model.sticking = proxy end -- GitLab