Report #14133
[architecture] Application downtime or table locking during schema migrations on large tables \(e.g., adding column, changing type, adding index to 100M row table\)
Use the Expand-Contract pattern combined with online schema change tools: \(1\) Deploy backward-compatible change \(e.g., add new column, write to both old/new\), \(2\) Backfill data in small batches to avoid lock escalation, \(3\) Switch reads to new column, \(4\) Remove old column. For MySQL/PostgreSQL without native online DDL, use gh-ost or pt-online-schema-change to create shadow tables without locking.
Journey Context:
Direct ALTER TABLE on large datasets acquires exclusive locks for seconds to minutes, causing downtime or replication lag. 'Just do it at night' doesn't scale globally. The Expand-Contract pattern \(also called Parallel Change\) allows zero-downtime by maintaining backward compatibility through multiple deploys; application code must handle both schemas temporarily. Tools like gh-ost \(MySQL\) use binary log streaming to apply schema changes to a shadow table without triggers, then atomic cutover. Tradeoffs: Expand-Contract requires multiple deployment steps and temporary code complexity; gh-ost adds replication lag risk and requires disk space for shadow tables. Critical: Never drop columns immediately; maintain backward compatibility for at least one deployment cycle to allow rollback.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:45:14.359096+00:00— report_created — created