Drop the default partition_id value from the partitionable tables
As a safety net for our partition effort to make sure that all records get a value, we've added the partition_id
column with default value 100
:
gitlabhq_development=# \d ci_builds_metadata
Table "public.ci_builds_metadata"
Column | Type | Collation | Nullable | Default
---------------------------+------------------------+-----------+----------+------------------------------------------------
id | bigint | | not null | nextval('ci_builds_metadata_id_seq'::regclass)
partition_id | bigint | | not null | 100
Indexes:
This value will be added to the routing table as well:
Partitioned table "public.p_ci_builds_metadata"
Column | Type | Collation | Nullable | Default
---------------------------+------------------------+-----------+----------+------------------------------------------------
id | bigint | | not null | nextval('ci_builds_metadata_id_seq'::regclass)
partition_id | bigint | | not null | 100
And because of this it will be added to the new partitions that will be created for the routing tables:
Table "gitlab_partitions_dynamic._test_gitlab_ci_builds_metadata_partition"
Column | Type | Collation | Nullable | Default
---------------------------+------------------------+-----------+----------+------------------------------------------------
id | bigint | | not null | nextval('ci_builds_metadata_id_seq'::regclass)
partition_id | bigint | | not null | 100
Partition of: p_ci_builds_metadata FOR VALUES IN ('99999')
It doesn't make sense to have a default value on the routing table after successfully attaching and switching the reads/writes to it because it points to the wrong partition. Updating the default value on the routing table to point to the current partition each time a new one is created seems like a lot of overhead.
Proposal
Remove default values from the routing tables after successfully proven that all writes populate correctly the partition_id
value.
Table | Column | Current default |
---|---|---|
ci_build_needs |
partition_id |
|
ci_build_pending_states |
partition_id |
|
ci_build_report_results |
partition_id |
|
ci_build_trace_chunks |
partition_id |
|
ci_build_trace_metadata |
partition_id |
|
ci_builds_runner_session |
partition_id |
|
ci_builds |
partition_id |
|
ci_job_artifacts |
partition_id |
|
ci_job_variables |
partition_id |
|
ci_pending_builds |
partition_id |
|
ci_pipeline_variables |
partition_id |
|
ci_pipelines |
partition_id |
|
ci_resources |
partition_id |
|
ci_running_builds |
partition_id |
|
ci_sources_pipelines |
partition_id |
|
ci_sources_pipelines |
source_partition_id |
|
ci_stages |
partition_id |
|
ci_unit_test_failures |
partition_id |
|
p_ci_builds_metadata |
partition_id |
|
p_ci_runner_machine_builds |
partition_id |
Edited by Marius Bobin