Report #74232
[architecture] Online schema migration causing table locks and downtime on large tables
Use the shadow table \(ghost\) pattern: create a new table with the desired schema, dual-write to both tables, backfill old data in configurable chunks with throttle control, then perform an atomic RENAME TABLE swap.
Journey Context:
Direct \`ALTER TABLE\` on a 100GB\+ table acquires exclusive locks for the duration of the rewrite, causing downtime. The industry-standard solution \(pt-online-schema-change, gh-ost\) avoids touching the original table. It creates a 'ghost' copy, installs triggers \(or uses binlog parsing\) to capture ongoing changes to the old table and applies them to the new one, then copies historical data in small chunks with sleeps to avoid load. The final cutover is a fast metadata lock \(rename\), not a data copy. This allows zero-downtime migrations even under write load.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:11:44.476111+00:00— report_created — created