Limited Offer

30% OFF Lifetime Access ($139) with code SYSTEM30

TOPIC #67Advanced 9 min read

Zero-Downtime Schema Migrations at Scale (gh-ost / pt-online-schema-change)

💡
Core Architecture Summary

Alter massive tables without locking: The Expand/Contract pattern, shadow tables, binlog streaming, and preventing metadata locks.

Key Glossary Concepts in this TopicAll Glossary Terms

01.1. Why `ALTER TABLE` Kills Production Systems

In traditional relational databases (MySQL, PostgreSQL), executing an ALTER TABLE statement (e.g., adding an index, changing a column data type, or renaming a column) requires acquiring an exclusive Metadata Lock (MDL) or an exclusive table write lock.

When executed on a table containing 100M+ rows:

  • The database engine rewrites the entire physical table on disk, which can take hours or even days.
  • While the table lock is held, all incoming application writes and concurrent transactional reads are blocked in a waiting queue.
  • Application thread pools instantly fill up with blocked connections, connection limits are breached, and the entire system cascades into a full-scale outage.

Even in modern PostgreSQL with ADD COLUMN ... DEFAULT NULL or CREATE INDEX CONCURRENTLY, long-running background queries can block the acquisition of brief metadata locks, creating queue pileups.

gh-ost Ghost Table Online Schema Migration Pipeline 👻

PRO Architecture Blueprint

gh-ost Ghost Table Online Schema Migration Pipeline 👻

Altering a 100-million row table with zero table locks using binary log streaming.

gh-ost Ghost Table Online Schema Migration Pipeline 👻
100%
Rendering visual architecture flowchart...
PRO & LIFETIME CURRICULUM

Unlock Topic #67: Zero-Downtime Schema Migrations at Scale (gh-ost / pt-online-schema-change)

You are viewing a preview. The full in-depth engineering deep dive, interactive simulators, architecture flowcharts, and self-assessment quizzes for this topic are available with Pro or Lifetime Access.

Production Deep Dive

Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.

Interactive Blueprints

Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.

Knowledge Assessment

Staff-level multiple-choice quiz questions with instant feedback and answer explanations.

Cross-Device Progress Sync

Firebase Google authentication automatically syncs your completed topics and quiz scores.

Rate This Architecture Chapter4.9 / 5.0 (38 ratings)

How clear and staff-actionable was this system breakdown?