Fully shard gpg_key_subkeys

Picks up on #553457 (closed) to gully shard the table.

Milestone %18.7

  • Prepare to shard table -> !214434

    • add user_id column
    • index user_id column
    • add foreign key constraint (not valid) on user_id column
    • add a trigger on user_id column to backfill from parent table gpg_keys
    • add a not null (not valid) constraint on the user_id column
    • backfill the user_id column using a single batched SQL update statement
    • test the backfill code
    • update db/docs/gpg_key_subkeys.yml by replacing desired_sharding_key with sharding_key
    • update spec/lib/gitlab/database/sharding_key_spec.rb to reflect the work in progress on the sharding key
  • verify the backfill completed successfully

  • verify all rows have user_id IS NOT NULL on .com

  • validate foreign key constraint

Milestone %18.8 (required stop)

Milestone %18.9

  • Fully shard table
    • finalize sharding key backfill
    • validate not null constraint on sharding key
Edited by Tomasz Skorupa