Report #93897
[architecture] Native ALTER TABLE on large tables locks the table causing downtime and replication lag
Use the shadow table pattern \(gh-ost or pt-online-schema-change\). Create a new table with the target schema, synchronize data using binlog streaming or triggers, then perform an atomic RENAME TABLE to cut over. Do not run direct ALTER on tables larger than 1GB in production.
Journey Context:
Native DDL operations typically require AccessExclusiveLock \(PostgreSQL\) or MetaData Lock \(MySQL\), blocking reads and writes for the duration of the rewrite. The shadow table avoids locks on the original table during the copy phase. gh-ost uses binary log streaming \(no triggers on the master\), reducing write amplification. pt-online-schema-change uses triggers. The cutover requires a brief lock to swap table names; this is the only downtime window. Foreign key constraints are problematic—they must be updated to point to the new table, which is complex and often unsupported by these tools.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:11:38.163504+00:00— report_created — created