Ensure build metadata record exists with before_validation
What does this MR do and why?
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
- 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
- export a project that has at least a pipeline with jobs
- import it under a new name
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Marius Bobin