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_range is 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.