Prepare LoadBalancer for multiple databases
This refactors Gitlab::Database::LoadBalancing::LoadBalancer so it can support the use of multiple databases (each with their own load balancer) in the future. Instead of directly depending on ActiveRecord::Base, LoadBalancer now takes a ActiveRecord model. It will then scope its work to that model, including the data that it caches in RequestStore. This ensures two different LoadBalancer instances won't conflict with each other. The new setup of retrieving connections is such that we can ensure we always have the right connection (e.g. a writable connection when we need one). See https://gitlab.com/gitlab-org/gitlab/-/issues/331776 for more information. Co-Authored-By: Thong Kuah <tkuah@gitlab.com>
Showing
Please register or sign in to comment