Skip to content

Don't create partitions for geo rake tasks

Patrick Bair requested to merge pb-fix-db-migrate-for-geo into master

What does this MR do and why?

Related issue #353888 (closed)

In !80677 (merged) some single-database rake tasks where enhanced to also call create_dynamic_partitions. This won't work if we're targeting the geo database and we don't yet have the other databases setup.

This MR addresses that by not attempting to manage partitions if we're migrating the geo database. There should be holistic handling of geo in rake tasks, which is captured in #353493, but this fixes the immediate problem.

How to set up and validate locally

We can recreate the error from the linked issue by simulating how this works, even without fully having geo running.

  1. Copy your database.yml to database_geo.yml, and change the names of the database from gitlabhq_<env> to gitlabhq_geo_env>.
  2. Change your database.yml to use the wrong port for the postgres connection (this simulates the main database not being setup)
  3. Create the geo database:
    rails db:create:geo
  4. Try to migrate the geo database:
    rails --trace db:migrate:geo

The last step will fail without the change, similar to the linked issue and the following:

Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/Users/pbair/Projects/gitlab-development-kit/postgresql/.s.PGSQL.6000"?
...
/Users/pbair/Projects/gitlab-development-kit/gitlab/lib/tasks/gitlab/db.rake:155:in `block (3 levels) in <main>'
/Users/pbair/Projects/gitlab-development-kit/gitlab/lib/tasks/gitlab/db.rake:169:in `block (4 levels) in <main>'
Tasks: TOP => gitlab:db:create_dynamic_partitions

With the fix from this branch, the task should succeed. You can also verify in the --trace output that the create_dynamic_partitions task never runs.

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