Why gh-ost Exists: Because pt-online-schema-change Will Ruin Your Weekend
GitHub built gh-ost after getting burned too many times by pt-online-schema-change taking down production during routine migrations. Released in 2016, it's their solution to the "why is our database locked up again?" problem.
The Real Problem with Triggers
Every other MySQL migration tool uses triggers. Triggers are fucking evil because they run in the same transaction as your application queries. First, they create metadata lock contention that can freeze your entire database - I've seen 30-second ALTER TABLE
operations turn into 10-minute deadlocks because triggers couldn't be installed. Then every INSERT
, UPDATE
, and DELETE
on your table has to execute trigger code, adding massive overhead to every transaction (I've seen 40-80% performance hits) on a table doing 10k writes/second. And once pt-osc starts? You can't actually stop it without data loss because the "throttle" option only pauses the copy phase while triggers keep firing and eating CPU. Your only choice is to let it finish or restore from backup.
Alright, Here's How gh-ost Fixes This Clusterfuck
OK, rant over. gh-ost reads from the MySQL binary log instead of using triggers, which fixes all this shit:
Actually Pausable: Run
echo throttle | socat - /tmp/gh-ost.sock
and it immediately stops all writes. Your database load drops to normal instantly. See interactive commands documentation.No Lock Contention: No triggers to install/remove means no metadata locks. The migration runs completely outside your application transactions. Read about MySQL's locking mechanisms.
Real Throttling: You can pause, resume, change chunk sizes, and even abort mid-migration without leaving your database in a broken state. Check the throttling documentation for all options.
The Catch
gh-ost isn't magic. It requires Row-Based Replication and MySQL 5.7+. Foreign keys are a no-go - you have to drop them before migration and recreate after. But honestly, if you're running MySQL in production at any scale, you should already have RBR enabled and foreign keys removed for performance reasons.
Who Actually Uses This
Version 1.1.7 was released December 20, 2024 with performance improvements and several bug fixes. GitHub uses it for their own production (obviously), along with companies like Shopify and others who got tired of pt-osc ruining their weekends. It has 12.9k stars on GitHub, which in database tool terms means "actually battle-tested." You can find the complete requirements and limitations in the official documentation.