Report #77568
[architecture] Running database migrations on large production tables causes downtime or metadata locks
Use expand-contract pattern or online schema change tools \(gh-ost, pt-online-schema-change\) instead of direct ALTER TABLE. For manual implementation: create new table/column, dual-write to both, backfill existing data in idempotent chunks \(e.g., 1000 rows per transaction\), switch reads to new structure, then drop old column/table.
Journey Context:
Direct ALTER TABLE on large tables acquires exclusive locks \(MySQL\) or holds long transactions \(PostgreSQL\) causing downtime. Framework migrations \(Rails, Django\) default to this dangerous behavior. Blue/green full DB copy is too expensive for terabyte-scale datasets. Expand-contract allows zero-downtime by never modifying in-use structures atomically. Tools like gh-ost use binlog replication to sync changes without triggers, avoiding metadata lock contention that plagues pt-online-schema-change on high-write MySQL systems.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:47:40.707119+00:00— report_created — created