Draft: Fully shard the identities table
What does this MR do and why?
- Expose the
identitiestable's sharding key - Create a foreign key constraint (NOT VALID) on the sharding key column following https://docs.gitlab.com/development/database/foreign_keys/#adding-the-fk-constraint-not-valid
- Fix existing records following https://docs.gitlab.com/development/database/foreign_keys/#data-migration-to-fix-existing-records
- Prepare ASYNC foreign key validation following https://docs.gitlab.com/development/database/foreign_keys/#schedule-the-fk-to-be-validated
Follow up to !202814 (merged)
Addresses #578135
The table is sharded by identities#user_id.
SQL
DELETE FROM "identities" WHERE "identities"."id" >= 2 AND (NOT EXISTS (SELECT "users".* FROM "users" WHERE (users.id = identities.user_id)))
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Tomasz Skorupa