Use partition_id filters in pipeline objects hierarchy

What does this MR do and why?

References

Related to gitlab-com/gl-infra/production#21562

Screenshots or screen recordings

Ci::Pipeline.find(1338523276).self_and_upstreams.to_a.pluck(:id).sort

Before: https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/49956/commands/148501
After: https://postgres.ai/console/gitlab/gitlab-production-ci/sessions/49956/commands/148502

 Ci::Pipeline.find(1338491531).self_and_downstreams.to_a.pluck(:id).sort

Before: https://postgres.ai/console/gitlab/gitlab-production-ci/sessions/49956/commands/148503
After: https://postgres.ai/console/gitlab/gitlab-production-ci/sessions/49956/commands/148504

Ci::Pipeline.find(1338520191).upstream_and_all_downstreams.to_a.pluck(:id).sort

Before: https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/49956/commands/148505
After: https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/49956/commands/148506

Cross project pipelines could have different partition_id values since they're also stand alone pipelines, so we can't force a static partition_id value in the query:

gitlabhq_dblab=# select * from ci_sources_pipelines where source_partition_id <> partition_id and source_project_id = 278964 limit 10;
    id    | project_id | source_project_id | source_job_id | partition_id | source_partition_id | pipeline_id | source_pipeline_id
----------+------------+-------------------+---------------+--------------+---------------------+-------------+--------------------
 95789908 |   14588374 |            278964 |    7134293498 |          101 |                 102 |  1338523276 |         1338520191
 95789966 |    7682093 |            278964 |    7134303620 |          101 |                 102 |  1338524089 |         1338521651
 72121355 |    7682093 |            278964 |    5727855928 |          100 |                 101 |  1103087919 |         1103087433
 72122112 |   14588374 |            278964 |    5727793688 |          100 |                 101 |  1103093907 |         1103077973
 95790101 |   14588374 |            278964 |    7134302561 |          101 |                 102 |  1338526500 |         1338521455
 72123160 |   14588374 |            278964 |    5727946995 |          100 |                 101 |  1103103999 |         1103100546
 72124598 |   40163745 |            278964 |    5728020388 |          100 |                 101 |  1103116256 |         1103112525
 72124577 |   14588374 |            278964 |    5727355787 |          100 |                 101 |  1103116139 |         1103010626
 72124586 |   14588374 |            278964 |    5727994175 |          100 |                 101 |  1103116272 |         1103107239
 72124644 |   14588374 |            278964 |    5728021214 |          100 |                 101 |  1103116749 |         1103112525
(10 rows)

How to set up and validate locally

MR acceptance checklist

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

Edited by Marius Bobin

Merge request reports

Loading