S Cells 1.0: ci_runners
sharding key
For Cells 1.0 we need a way to make sure that every entity in Organization 1 doesn't have links to any other Organization.
To do that, we need to add sharding keys, see more in https://docs.gitlab.com/ee/architecture/blueprints/organization/isolation.html
ci_runners
table creates a challenge here:
- it doesn't have a sharding key yet
- it can belong to project/group
- the sharding key would be nullable because runner can be an instance runner and not belong to anything
- we allow users to link project runners to any other project with no restrictions
- There are tables which depend on the runner, e.g.
runner_machines
which will inherit all the same limitation, including sharding key being nullable
Proposed solution
-
!166308 (merged): Add partition prefix to runner tokens. -
#493256 (closed): Add sharding_key_id
column toci_runners
table-
%17.5: Backfill sharding_key_id
- Update the app to populate
sharding_key_id
for new runners
- Update the app to populate
-
%17.6: Post-backfill cleanup (Release N+1) -
Optional %17.6: if we take the approach of only copying valid records to the partitioned table.-
Delete invalid records. -
Delete project and group runners belonging to n... (#498019 - closed) -
Validate sharding key constraints.
-
-
-
#500447 (closed): Create routing table and partitions -
Create ci_runners_e59bb2812d
routing table (exempt from sharding), and its 3 partitions:-
instance_type_ci_runners_e59bb2812d
will be attached to partition 1, and will be exempt from sharding. -
group_type_ci_runners_e59bb2812d
will be attached to partition 2, and will be sharded bynamespace: namespace_id
. -
project_type_ci_runners_e59bb2812d
will be attached to partition 3, and will be sharded byproject: project_id
.
-
-
Mimic LFK definitions from ci_runners
inconfig/gitlab_loose_foreign_keys.yml
for the newci_runners_e59bb2812d
. -
Add missing FK definition between ci_runners_e59bb2812d
andci_runner_projects
(resolves #369084 (closed) for the partitioned table) -
Create triggers to keep ci_runners
and each of the partitioned tables in sync.
-
-
See if we want to enforce unique encrypted tokens across partitions with a trigger: http://blog.ioguix.net/postgresql/2015/02/05/Partitionning-and-constraints-part-1.html. -
Copy data to partitioned table ( enqueue_partitioning_data_migration
).-
%17.6:
-
Backfill ci_runners_e59bb2812d table (!166520 - merged). This is estimated to take just over 2 hours for .com.
-
- after next required stop (%17.9):
-
%17.6:
-
Add foreign key between ci_runner_projects and ... (#369084 - closed) -
Ensure sharding_key_id
values are correctly maintained: -
Adapt FKs: -
ci_running_builds.runner_id
will need to point toci_runners_e59bb2812d
- Instance runners:
-
Make ci_cost_settings
'sfk_rails_6a70651f75
referenceinstance_type_ci_runners_e59bb2812d
table, since this table only applies to instance runners.
-
- Group runners:
-
Add an LFK pointing to namespaces
. -
Make ci_runner_namespaces
'sfk_rails_8767676b7a
referencegroup_type_ci_runners_e59bb2812d
table, since this table only applies to group runners.
-
- Project runners:
-
Add an LFK pointing to projects
. -
ci_runner_projects
doesn't have a FK pointing toci_runners
. We can add a new FK pointing toproject_type_ci_runners_e59bb2812d
, after -
#504963 (closed): Call replace_with_partitioned_table
and setCi::Runner.primary_key = [:id, :runner_type]
. ensuring that no records exist that point to missing project runners.
-
-
-
Replace ci_runners with partitioned table (#504963 - closed) -
Replace ci_runner_machines with partitioned table (#504965 - closed) -
Optimize code that can take advantage of runner_type PK, such as Ci::Runner.find
when we know the runner type in addition to the ID. -
#516060 (closed): Once everything is verified to be running as expected, drop ci_runners_archived
table. -
!171172 (merged): Change Ci::Runner#owner_project
to returnproject_id
, instead of relying on a join withci_project_runners
. -
Add organization_id column to runner tables (#523694 - closed) -
Add logic to validate organization_id field in ... (#548139 - closed) -
Finalize organization_id backfill migrations (#523850 - closed) -
Add check_organization_id_nullness constraint c... (#523851 - closed) -
Drop check constraints on sharding_key_id colum... (#557226 - closed) -
Validate check_organization_id_nullness constra... (#523852) -
Column organization_id on runner tables should ... (#525293 - closed) -
Ignore sharding_key_id column in runner models (#547654 - closed) -
Drop sharding_key_id column from runner tables (#547650 - closed) -
Bonus: We could drop ci_runner_namespaces
if we don't plan on allowing sharing group runners across multiple groups. -
Mark db/docs/ci_runners.yml
asexempt_from_sharding: true
. This will affect Org mover as it is planned to skipexempt_from_sharding
tables from org mover. -
Open a follow-up issue to address impact on Org Mover
Edited by Pedro Pombeiro - OOO from Oct 13-24