Skip to content

Fix gitlab:setup task for multiple databases

Patrick Bair requested to merge 352770-fix-gitlab-setup-for-multiple-dbs into master

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

  1. Setup multiple databases according to https://docs.gitlab.com/ee/development/database/multiple_databases.html#development-setup
  2. Open up a psql session to both gitlabhq_development and gitlabhq_development_ci
  3. 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
  4. From the terminal output, verify the task recreates and seeds the database in spite of the open connections
  5. Optionally you can verify your psql sessions to each database were disconnected by running any query, like
    psql> 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.

Edited by Patrick Bair

Merge request reports