Skip to content

Adding logic to populate build_names table

Max Fan requested to merge 423904-update-build-names into master

What does this MR do and why?

Adding logic to populate build_names table

When a pipeline is triggered, builds names will be copied to p_build_names

Example Upsert_all query

[32] pry(main)> Ci::BuildName.upsert_all(builds_upsert_data, unique_by: [:build_id, :partition_id])ion_id])
  Ci::BuildName Bulk Upsert (4.3ms)  INSERT INTO "p_ci_build_names" ("build_id","partition_id","name","project_id") VALUES (9056718, 100, 'deploy-jb2', 285), (9057429, 100, 'deploy-job', 285), (9058140, 100, 'build-job', 285), (9058851, 100, 'build-job2', 285), (9059562, 100, 'build-job3', 285), (9060273, 100, 'unit-test-job', 285), (9060984, 100, 'lint-test-job', 285), (9061695, 100, 'another-test', 285), (9062406, 100, 'deploy-jb2', 285), (9063117, 100, 'deploy-job', 285), (9063828, 100, 'build-job', 285), (9064539, 100, 'build-job', 285), (9065250, 100, 'build-job', 285), (9065961, 100, 'build-job2', 285), (9066672, 100, 'build-job3', 285), (9067383, 100, 'unit-test-job', 285), (9068094, 100, 'lint-test-job', 285), (9068805, 100, 'another-test', 285), (9069516, 100, 'deploy-jb2', 285), (9070227, 100, 'deploy-job', 285), (9070938, 100, 'build-job', 285), (9071649, 100, 'build-job', 285), (9072360, 100, 'build-job', 285), (9073071, 100, 'build-job', 285), (9073782, 100, 'build-job', 285), (9074493, 100, 'build-job', 285), (9075204, 100, 'build-job2', 285), (9075915, 100, 'build-job3', 285), (9076626, 100, 'unit-test-job', 285), (9077337, 100, 'lint-test-job', 285), (9078048, 100, 'another-test', 285), (9078759, 100, 'deploy-jb2', 285), (9079470, 100, 'deploy-job', 285), (9080181, 100, 'build-job', 285), (9080892, 100, 'build-job', 285), (9081603, 100, 'build-job', 285), (9082314, 100, 'build-job', 285), (9083025, 100, 'build-job', 291), (9083736, 100, 'lint-test-job', 291), (9084447, 100, 'deploy-job', 291), (9085158, 100, 'build-job', 291), (9085869, 100, 'build-job', 291), (9086580, 100, 'build-job', 285), (9087291, 100, 'build-job2', 285), (9088002, 100, 'build-job3', 285), (9088713, 100, 'unit-test-job', 285), (9089424, 100, 'lint-test-job', 285), (9090135, 100, 'another-test', 285), (9090846, 100, 'deploy-jb2', 285), (9091557, 100, 'deploy-job', 285), (9092268, 100, 'build-job', 285), (9092979, 100, 'build-job', 285), (9093690, 100, 'build-job', 285), (9094401, 100, 'build-job2', 285), (9095112, 100, 'build-job3', 285), (9095823, 100, 'unit-test-job', 285), (9096534, 100, 'lint-test-job', 285), (9097245, 100, 'another-test', 285), (9097956, 100, 'deploy-jb2', 285), (9098667, 100, 'deploy-job', 285), (9099378, 100, 'build-job', 285), (9100089, 100, 'build-job2', 285), (9100800, 100, 'build-job3', 285), (9101511, 100, 'unit-test-job', 285), (9102222, 100, 'lint-test-job', 285), (9102933, 100, 'another-test', 285), (9103644, 100, 'deploy-jb2', 285), (9104355, 100, 'deploy-job', 285), (9105066, 100, 'build-job', 285), (9105777, 100, 'build-job2', 285), (9106488, 100, 'build-job3', 285), (9107199, 100, 'unit-test-job', 285), (9107910, 100, 'lint-test-job', 285), (9108621, 100, 'another-test', 285), (9109332, 100, 'deploy-jb2', 285), (9110043, 100, 'deploy-job', 285), (9110754, 100, 'build-job', 285), (9111465, 100, 'build-job2', 285), (9112176, 100, 'build-job3', 285), (9112887, 100, 'unit-test-job', 285), (9113598, 100, 'lint-test-job', 285), (9114309, 100, 'another-test', 285), (9115020, 100, 'deploy-jb2', 285), (9115731, 100, 'deploy-job', 285), (9116442, 100, 'build-job', 285), (9117153, 100, 'build-job2', 285), (9117864, 100, 'build-job3', 285), (9118575, 100, 'build-job2', 285), (9119286, 100, 'build-job3', 285), (9119997, 100, 'build-job', 285), (9120708, 100, 'build-job2', 285), (9121419, 100, 'build-job3', 285), (9122130, 100, 'unit-test-job', 285), (9122841, 100, 'lint-test-job', 285), (9123552, 100, 'another-test', 285), (9124263, 100, 'deploy-jb2', 285), (9124974, 100, 'deploy-job', 285), (9125685, 100, 'build-job', 285), (9126396, 100, 'build-job2', 285), (9127107, 100, 'build-job2', 285) ON CONFLICT ("build_id","partition_id") DO UPDATE SET "name"=excluded."name","project_id"=excluded."project_id" RETURNING "build_id","partition_id" /*application:console,db_config_name:ci,console_hostname:MaxPro.lan,console_username:maxfan,line:(pry):44:in `__pry__'*/

Sample Query

https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/27187/commands/84497

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. Running a pipeline or retrying jobs should populate the new table p_ci_build_names

Related to #423904 (closed)

Edited by Max Fan

Merge request reports