Fix gitlab:setup task for multiple databases
What does this MR do and why?
Related to #352770 (closed)
Update the gitlab:setup
rake task to terminate all connections against all configured databases, rather than just the database pointed at to by ActiveRecord::Base.connection
. This is being done as part of the database decomposition project.
How to set up and validate locally
- Setup multiple databases according to https://docs.gitlab.com/ee/development/database/multiple_databases.html#development-setup
- Open up a
psql
session to bothgitlabhq_development
andgitlabhq_development_ci
- Run the rake task, using a separate connection for each database, and responding
yes
when prompted$ GITLAB_USE_MODEL_LOAD_BALANCING=true rails gitlab:setup
- From the terminal output, verify the task recreates and seeds the database in spite of the open connections
- Optionally you can verify your
psql
sessions to each database were disconnected by running any query, likepsql> select 1; FATAL: terminating connection due to administrator command server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Succeeded.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Patrick Bair