Skip to content

Use lazy init to correctly populate db list

Patrick Bair requested to merge pb-fix-gitlab-database-load-order into master

What does this MR do and why?

Update Gitlab::Database.databases to explicitly reference base models that can manage their own database connections. This prevents issues where the database list didn't contain secondary database connections, because their models were not loaded prior to the initialization of the list.

How to set up and validate locally

  1. Update configuration to use multiple databases
  2. In rails console, run Gitlab::Database.databases
  3. Verify the returned hash has an entry for both :main and :ci

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Patrick Bair

Merge request reports