Cells ADR 008: Cluster wide unique database sequences
Context
Having non-overlapping unique sequences across the cluster is necessary for moving organizations between cells, this was highlighted in core-platform-section/-/epics/3 and different solutions were discussed in https://gitlab.com/gitlab-org/core-platform-section/data-stores/-/issues/102.
Decision
All cells will have bigint IDs on creation. While provisioning, each of them will get a range of sequences to use from the Topology Service.
Topology service uses the logic explained in here to compute the sequence range, which is used to set
minval, maxval for all existing and newly created sequence IDs.
- Once the database(s) are loaded,
gitlab:db:alter_cell_sequences_rangeis called to alter sequences range. - The above rake internally registers a EVENT TRIGGER alter_new_sequences_range to set the correct sequence range for new IDs.
Alternatives
Below are the different solutions considered for this problem.
- Solution 1: Global Service to claim sequences
- Solution 2: Converting all int IDs to bigint to generate uniq IDs
- Solution 3: Using composite primary key [(existing PKs), original cell ID]
- Solution 4: Use bigint IDs only for Cell
- Solution 5: Using Logical replication
Last modified March 4, 2025: Includes altering sequence range of new IDs in the docs (
a25f7eb8)
