Convert ci_builds_metadata.id to bigint - Step 2: Finalize background migrations and swap columns
The ci_builds_metadata
table is one of the largest tables in GitLab's database still uses an integer (int4
) Primary Key. It has a high Primary Key Overflow risk as can be seen on its tracking issue.
With #325616 (closed) we have started the process of converting it to bigint
(int8
) type.
In this issue we'll address the second step of the process:
-
Clean up the background migrations
-
Drop the
DEFAULT 0
from the affected columns -
Concurrently add a Unique index for the PK (
ci_builds_metadata_pkey
) -
Concurrently add any additional indexes that include the converted columns
"index_ci_builds_metadata_on_build_id" UNIQUE, btree (build_id) "index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts" btree (build_id) WHERE has_exposed_artifacts IS TRUE "index_ci_builds_metadata_on_build_id_and_id_and_interruptible" btree (build_id) INCLUDE (id) WHERE interruptible = true
-
Single Transaction: Drop old PK, define new PK, swap sequence, swap columns
-
Single Transaction: Drop old FK, define new FK (as invalid), swap columns, validate FK
-
Drop the old columns
Previous Implementation Issue: #325616 (closed)
Related Tracking Issue: #276020 (closed)