Fix gitlab:setup when connections are shared
What does this MR do and why?
This task was originally changed to support multiple databases as part of #352770 (closed)
Fix the gitlab:setup
rake task when multiple databases are configured to share the same primary connection. The task currently fails with:
ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
because it terminates all the connections to main
, and then tries to terminate all connections to ci
, but the connection to ci
has already been terminated in the first step, since ci
points at main
.
Instead, if ci
isn't setup to use database_tasks
, we should skip over it.
How to set up and validate locally
Since this task will delete your development db, you can test it against a separate database.
- Create
development
andtest
databases:create database foobar_development; create database foobar_test;
- Update your
database.yml
to point at these (other usual parameters like host, user, password, etc. omitted):development: main: database: foobar_development ci: database: foobar_development database_tasks: false test: main: database: foobar_test ci: database: foobar_test database_tasks: false
- Run the rake task
rails gitlab:setup
. Onmaster
, this will fail with the error:ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
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