Report #63576
[architecture] Zero-downtime MySQL schema migration cut-over strategy with gh-ost
Use a triggerless online schema change tool \(gh-ost\) that reads the binlog to sync a shadow table, then performs an atomic RENAME TABLE swap with a brief write-lock \(typically <500ms\). Never use native ALTER or trigger-based tools \(pt-online-schema-change\) on tables with high write concurrency or foreign keys.
Journey Context:
Native MySQL ALTER TABLE rewrites the entire table, holding a metadata lock \(MDL\) that blocks all writes for the duration \(minutes to hours for large tables\), causing application downtime. Trigger-based tools \(Percona pt-online-schema-change\) create three triggers \(INSERT/UPDATE/DELETE\) on the original table to propagate changes to a shadow table, but triggers execute in the same transaction, adding latency \(often 2-5x write amplification\) to the hot path and risking deadlocks on high-concurrency tables. Foreign keys with trigger tools create cascading lock acquisitions that often deadlock. gh-ost \(GitHub's Online Schema Transformer\) reads the MySQL binlog asynchronously \(like a replica\) to sync the shadow table, imposing near-zero load on the master during the copy phase and allowing fine-grained throttling. The critical insight is the cut-over strategy: gh-ost stops binlog application briefly, acquires a write lock, verifies consistency \(checksum\), and executes an atomic RENAME TABLE \(swap\) in milliseconds. This eliminates the foreign key trigger deadlock problem and the write amplification of triggers. The tradeoff is gh-ost requires binlog\_format=ROW and a replica or direct master connection, and cannot be used on tables with no primary key.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:11:55.424401+00:00— report_created — created