Skip to content

Draft: Prepare async index for ci_pipelines.partition_id related

Tianwen Chen requested to merge 428999-prepare-async-index into master

What does this MR do and why?

Prepare async index for ci_pipelines.partition_id related

As titled, this is the first step of creating indexes asynchronously. See guideline at https://docs.gitlab.com/ee/development/database/adding_database_indexes.html#schedule-the-index-to-be-created

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

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

  1. Run the following commands:

    ./scripts/regenerate-schema
    RAILS_ENV=test bin/rails runner 'Feature.enable :database_async_index_operations'
    RAILS_ENV=test bin/rake gitlab:db:execute_async_index_operations:all
  2. Confirm the following indexes are created in TEST environment

    psql gitlabhq_test -h $PATH_TO_POSTGRESQL/gitlab-development-kit/postgresql
     "index_ci_pipelines_on_id_and_partition_id" UNIQUE, btree (id, partition_id)
     "index_ci_pipelines_on_id_convert_to_bigint_and_partition_id" UNIQUE, btree (id_convert_to_bigint, partition_id)
     "index_ci_pipelines_on_project_id_and_iid_and_partition_id" UNIQUE, btree (project_id, iid, partition_id) WHERE iid IS NOT NULL
  3. Run the following commands to restore the feature flag:

    RAILS_ENV=test bin/rails runner 'Feature.disable :database_async_index_operations'

Related to #428999

Edited by Tianwen Chen

Merge request reports