Skip to content

Use the same gitlab_main schema when ensure_..._is_finished

Dylan Griffith requested to merge use-gitlab-main-for-ensure-bbm into master

What does this MR do and why?

Use the same gitlab_main schema when ensure_..._is_finished

As discovered in !137997 (comment 1687949469) we need to use the same schema for the calls to ensure_batched_background_migration_is_finished that were used when we called queue_batched_background_migration. Even though the gitlab_main_cell is the same database as gitlab_main the schema is being stored in the DB and it's used to retrieve the matching batched background migration.

There was also another inconsistency we probably want to solve here which is the fact that we load the BBM from the DB in 2 different ways in the same call stack:

  1. https://gitlab.com/gitlab-org/gitlab/-/blob/60ed42efa8660945c13013e6424692aae5f17eb7/lib/gitlab/database/migrations/batched_background_migration_helpers.rb#L217
    1. gitlab_schema is derived from Gitlab::Database.gitlab_schemas_for_connection(connection)
  2. https://gitlab.com/gitlab-org/gitlab/-/blob/60ed42efa8660945c13013e6424692aae5f17eb7/lib/gitlab/database/migrations/batched_background_migration_helpers.rb#L146
    1. gitlab_schema is derived from gitlab_schema_from_context

Likely gitlab_schema_from_context is the correct one but our early return logic is implemented using Gitlab::Database.gitlab_schemas_for_connection(connection).

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

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

Merge request reports