Skip to content

Ensure partitioned tables have at least one partition attached for each database

Krasimir Angelov requested to merge structure-sql-partitions-dump into master

What does this MR do and why?

The problem we have is described in #366597 (closed).

This MR attempts to solve it by updating Gitlab::Database::Partitioning.sync_partitions in a way so that we can ask it to create at least one partition in every database for each partitioned table.

How to set up and validate locally

  1. When on master - git checkout master
  2. Run bundle exec rails db:migrate
  3. There will be changes in structure.sql, even if local schema matches it exactly - git diff db/structure.sql
  4. Switch to the branch from this MR - git checkout structure-sql-partitions-dump
  5. Run bundle exec rails db:migrate again (see !91444 (comment 1085949952))
  6. There should be no changes in structure.sql - git diff db/structure.sql, and tables will have 1 partition in ci:
    $ gdk psql -d gitlabhq_development_ci
    gitlabhq_development_ci=# \d audit_events -- Will report "Number of partitions: 0"

To restore the database to the state before this MR execute \d+ for each of these tables and drop the partition listed

  • gdk psql -d gitlabhq_development_ci
  • \d+ audit_events
  • \d+ web_hook_logs
  • \d+ verification_codes
  • \d+ incident_management_pending_issue_escalations
  • \d+ incident_management_pending_alert_escalations

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Krasimir Angelov

Merge request reports