Skip to content

Ensure build metadata record exists with before_validation

Marius Bobin requested to merge mb-ci-fix-metadata-partitioning-for-import into master

What does this MR do and why?

#387940 (closed)

This MR fixes the cascading of partition_id values to p_ci_build_metadata records for imports: #387301 (comment 1236757887)

More details in comments.

How to set up and validate locally

  1. change the default values for all partitionable tables:
    • VERSION=20221220131020 bin/rails db:migrate:down:ci
    • comment out the Gitlab.com? check
    • VERSION=20221220131020 bin/rails db:migrate:up:ci
    • restart Rails and Sidekiq
  2. export a project that has at least a pipeline with jobs
  3. import it under a new name
  4. check the database that all records(pipeline, builds, metadata) have the same partition_id value:
gitlabhq_development_ci=# select count(*) from ci_pipelines where project_id = 37 and partition_id = 101;
 count
-------
     0
(1 row)

gitlabhq_development_ci=# select count(*) from ci_pipelines where project_id = 37 and partition_id = 100;
 count
-------
    10
(1 row)

gitlabhq_development_ci=# select count(*) from ci_builds where project_id = 37 and partition_id = 100;
 count
-------
  2700
(1 row)

gitlabhq_development_ci=# select count(*) from ci_builds where project_id = 37 and partition_id = 101;
 count
-------
     0
(1 row)

gitlabhq_development_ci=# select count(*) from p_ci_builds_metadata where build_id in( select id from ci_builds where project_id = 37) and partition_id = 101;
 count
-------
     0
(1 row)

gitlabhq_development_ci=# select count(*) from p_ci_builds_metadata where build_id in( select id from ci_builds where project_id = 37) and partition_id = 100;
 count
-------
  2700
(1 row)

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 Marius Bobin

Merge request reports

Loading