Ensure partitioned tables have at least one partition attached for each database
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
- When on master -
git checkout master
- Run
bundle exec rails db:migrate
- There will be changes in
structure.sql
, even if local schema matches it exactly -git diff db/structure.sql
- Switch to the branch from this MR -
git checkout structure-sql-partitions-dump
- Run
bundle exec rails db:migrate
again (see !91444 (comment 1085949952)) - There should be no changes in
structure.sql
-git diff db/structure.sql
, and tables will have 1 partition inci
:$ 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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Krasimir Angelov