Skip to content

[REVERTED] Add ci_runner_machine_builds partitioned join table

What does this MR do and why?

Describe in detail what your merge request does and why.

This MR addresses #390858 (closed) as a first step to replacing the use of ci_builds_metadata.runner_machine_id with a new, lighter specific table to join ci_builds records with ci_runner_machines records (which represent the runner machine that executed the build).

TODO in follow-up MR:

  • remove the association in the ci_builds_metadata table.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Database migration logs

up
main: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: migrating =========
main: -- execute("CREATE TABLE p_ci_runner_machine_builds (\n  partition_id bigint DEFAULT 100 NOT NULL,\n  build_id bigint NOT NULL,\n  runner_machine_id bigint NOT NULL,\n  PRIMARY KEY (partition_id, build_id),\n  CONSTRAINT fk_bb490f12fe_p FOREIGN KEY (partition_id, build_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE\n)\nPARTITION BY LIST (partition_id);\n\nCREATE INDEX index_ci_runner_machine_builds_on_runner_machine_id ON p_ci_runner_machine_builds USING btree (runner_machine_id);\n\nCREATE TABLE gitlab_partitions_dynamic.ci_runner_machine_builds_100\nPARTITION OF p_ci_runner_machine_builds\nFOR VALUES IN (100);\n")
main:    -> 0.0031s
I, [2023-02-16T19:02:52.056568 #25005]  INFO -- : Database: 'main', Table: 'p_ci_runner_machine_builds': Lock Writes
I, [2023-02-16T19:02:52.057695 #25005]  INFO -- : {:method=>"with_lock_retries", :class=>"gitlab:db:lock_writes", :message=>"Lock timeout is set", :current_iteration=>1, :lock_timeout_in_ms=>100}
I, [2023-02-16T19:02:52.058039 #25005]  INFO -- : {:method=>"with_lock_retries", :class=>"gitlab:db:lock_writes", :message=>"Migration finished", :current_iteration=>1, :lock_timeout_in_ms=>100}
main: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: migrated (0.0173s)

ci: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: migrating =========
ci: -- execute("CREATE TABLE p_ci_runner_machine_builds (\n  partition_id bigint DEFAULT 100 NOT NULL,\n  build_id bigint NOT NULL,\n  runner_machine_id bigint NOT NULL,\n  PRIMARY KEY (partition_id, build_id),\n  CONSTRAINT fk_bb490f12fe_p FOREIGN KEY (partition_id, build_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE\n)\nPARTITION BY LIST (partition_id);\n\nCREATE INDEX index_ci_runner_machine_builds_on_runner_machine_id ON p_ci_runner_machine_builds USING btree (runner_machine_id);\n\nCREATE TABLE gitlab_partitions_dynamic.ci_runner_machine_builds_100\nPARTITION OF p_ci_runner_machine_builds\nFOR VALUES IN (100);\n")
ci:    -> 0.0031s
ci: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: migrated (0.0095s)
down
main: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: reverting =========
main: -- drop_table(:p_ci_runner_machine_builds)
main:    -> 0.0046s
main: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: reverted (0.0083s)

  11.59s user 5.24s system 68% cpu 24.566 total
ci: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: reverting =========
ci: -- drop_table(:p_ci_runner_machine_builds)
ci:    -> 0.1721s
ci: == 20230215074223 AddCiRunnerMachineBuildsPartitionedTable: reverted (0.1854s)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports