Connection pools of all configured databases are properly sized

We need a way to consistently size pools in config/initializers/database_config.rb by likely traversing all db configs to ensure that each pool has at least of Gitlab::Database.default_pool_size size.

Problem

  1. Our pool_size by default is like 5 connections. We do (dynamic) runtime overwrite of the connection pool size looking at number of threads (+ headroom). We manually re-establish connection on ActiveRecord::Base in config/initializers/database_config.rb. We today do it only for the AR::Base and Geo.

  2. This has two challenges:

  • Ordering: as initialisers are loaded lexicographically. Currently the database_config.rb needs to always be executed before load_balancing.rb
  • This today works on a limited set of models
Edited by Kamil Trzciński