gh-ost: MySQL Schema Migration Tool - AI-Optimized Reference
Overview
gh-ost is GitHub's MySQL schema migration tool that uses binary log reading instead of triggers to avoid production failures. Built after pt-online-schema-change caused repeated production outages.
Critical Requirements
- MySQL Version: 5.7+ only
- Replication: Row-Based Replication (RBR) required
- Foreign Keys: Must drop before migration, recreate after
- Primary Key: Single-column PK or unique index required (no composite keys)
Key Advantages Over pt-online-schema-change
Trigger Problems Solved
- No Metadata Lock Contention: pt-osc triggers create 30-second operations that become 10-minute deadlocks
- No Transaction Overhead: pt-osc adds 40-80% performance hit on tables with 10k writes/second
- Actually Pausable:
echo throttle | socat - /tmp/gh-ost.sock
stops all writes instantly - Safe Failure: Clean artifacts with no data loss vs pt-osc corruption requiring backup restore
Performance Impact
- gh-ost: 15-20% load on master during migration
- pt-osc: 40-60% load on busy tables
Critical Failure Modes
Binary Log Position Failures
Error: "Error 1236: Could not find first log file name in binary log index file"
Cause: Binary logs rotated during migration
Prevention: Set expire_logs_days
≥ 7 for large migrations
Recovery: None - restart migration from beginning
MySQL 8.0.28 Connection Killing
Error: "Connection was killed"
Cause: Long-running SELECT queries killed during operations
Solution: Set --mysql-timeout=300
Primary Key Requirements
Error: "Cannot determine table's PRIMARY KEY"
Cause: No PK or composite keys only
Solution: Add surrogate PK column before migration
Performance Benchmarks (Percona 3GB sysbench table)
Load Level | pt-osc Performance | gh-ost Performance | Winner |
---|---|---|---|
Idle | ~2x faster | Baseline | pt-osc |
Light | ~2x faster | Baseline | pt-osc |
Heavy (40% capacity) | 12% impact, completed | Could not complete | pt-osc |
Reality: gh-ost's single-threaded binlog processing hits walls on write-heavy workloads
Table Size Limits
- < 100GB: 2-4 hours, reliable
- 100GB - 1TB: 8-24 hours, plan carefully
- > 1TB: Multi-day migrations, high failure risk
- Largest Success: 5TB table in 3 days
Cloud Provider Gotchas
AWS RDS
- Requires
log_bin_trust_function_creators=1
- Automated backups interfere with binlog reading
- Some configurations restrict binlog access
Google Cloud SQL
- Requires point-in-time recovery enabled
- Aggressive binlog retention (3 days vs expected 7)
Azure MySQL
- Requires specific binlog access permissions
- Documentation insufficient for setup
Manual Cleanup Required
When migrations fail, manual cleanup needed:
DROP TABLE IF EXISTS your_table_gho; -- Ghost table
DROP TABLE IF EXISTS your_table_ghc; -- Changelog table
Interactive Commands
- Pause:
echo throttle | socat - /tmp/gh-ost.sock
- Resume:
echo no-throttle | socat - /tmp/gh-ost.sock
- Status: Various status commands available via socket
When to Use gh-ost vs pt-osc
Use gh-ost When:
- Safety is priority over speed
- Need true pause/resume capability
- Working with tables that have heavy write load
- Can drop foreign keys
- Have MySQL 5.7+ with RBR
Use pt-osc When:
- Foreign keys cannot be dropped
- Maximum speed required
- Working with legacy MySQL versions
- Simple schemas without complex constraints
Common Configuration Flags
--max-lag-millis=1500
: Pause when replication lag exceeds threshold--chunk-size=1000
: Rows copied per operation (increase for better performance)--exact-rowcount
: Better progress tracking for large tables--test-on-replica
: Safe testing before production run--serve-socket-file
: Enable interactive commands
Migration Planning Checklist
Pre-Migration
- Verify RBR enabled
- Check binary log retention settings
- Drop foreign keys
- Test on replica first
- Plan maintenance window (2-3x estimated time)
During Migration
- Monitor replication lag
- Watch for binlog rotation
- Keep interactive commands ready
- Monitor application performance
Post-Migration
- Recreate foreign keys
- Clean up ghost tables if failed
- Verify data integrity
- Update application configurations
Resource Requirements
- Time: 2-3x longer than pt-osc but safer
- Expertise: Requires understanding of MySQL replication
- Infrastructure: Replica access for binlog reading
Latest Version
v1.1.7 (December 20, 2024) with performance improvements and bug fixes
Adoption Indicators
- 12.9k GitHub stars (indicates production battle-testing)
- Used by GitHub, Shopify, and other high-scale companies
- Active development and bug fixes
Useful Links for Further Investigation
Docs That Don't Suck
Link | Description |
---|---|
GitHub Repository | Start here. This repository has 12.9k stars, indicating that actual people use gh-ost in production and generally find it reliable and effective for their database migration needs. |
Latest Release (v1.1.7) | Download the binary for the latest release, v1.1.7, which was published on December 20, 2024, and includes important bug fixes that are crucial for stable operation. |
Triggerless Design Explanation | Understand the unique triggerless design of gh-ost, which differentiates it from other migration tools and is essential knowledge to avoid confusion and debugging issues. |
Interactive Commands Reference | A comprehensive reference for interactive commands, crucial for managing and recovering from complex migration scenarios, as proven during the challenging migration disaster of 2024. |
Requirements and Limitations | Review all the critical requirements and potential limitations of gh-ost to understand common pitfalls and avoid unexpected issues or surprises during implementation. |
Command-Line Flags | A complete listing of all available command-line flags for gh-ost, essential for configuring and controlling its behavior, though be aware of the extensive number of options. |
Testing on Replica | Guidelines for safely testing gh-ost operations on a replica database, a crucial step to validate changes and prevent production outages before deployment. |
AWS RDS Configuration | Specific setup instructions for configuring gh-ost with AWS RDS, detailing the necessary steps and outlining any particular limitations that may apply to this environment. |
Azure Database for MySQL | This document provides Azure-specific configuration details for integrating gh-ost with Azure Database for MySQL, emphasizing the distinct setup requirements compared to AWS RDS. |
Google Cloud SQL Guide | This guide details the process of setting up external replicas for Google Cloud SQL, a necessary step to ensure proper binlog access for gh-ost operations and successful schema migrations. |
Percona's gh-ost vs pt-osc Benchmarks | Detailed performance benchmarks from Percona comparing gh-ost against pt-online-schema-change, offering objective data to inform your choice of online schema migration tool. |
Production Issues and Solutions | A curated list of GitHub issues specifically tagged with production problems, providing insights into common challenges and their solutions encountered by other users. |
Common Problems FAQ | This community-maintained FAQ provides a comprehensive list of frequent issues encountered with gh-ost, along with practical solutions and fixes to help users quickly resolve common problems. |
Bytebase: gh-ost vs pt-osc Comparison | An updated comparison from 2025 by Bytebase, evaluating gh-ost against pt-online-schema-change and offering practical advice on selecting the appropriate tool for different scenarios. |
Vitess Online DDL Comparison | An analysis of how Vitess's online DDL capabilities compare to gh-ost, specifically focusing on their suitability and performance for large-scale database deployments. |
Bytebase gh-ost Integration | Instructions on how to effectively integrate gh-ost into existing database CI/CD workflows, streamlining online schema migration processes for MySQL databases. |
Database Schema Change Management | This resource outlines best practices for performing online schema changes in MySQL using gh-ost, providing guidance on establishing robust and reliable processes for production database environments. |
Related Tools & Recommendations
pt-online-schema-change - The Tool That Prevents 3AM Disaster Calls
Change MySQL table schemas without locking everyone out for 6 hours.
Migrate JavaScript to TypeScript Without Losing Your Mind
A battle-tested guide for teams migrating production JavaScript codebases to TypeScript
jQuery - The Library That Won't Die
Explore jQuery's enduring legacy, its impact on web development, and the key changes in jQuery 4.0. Understand its relevance for new projects in 2025.
How These Database Platforms Will Fuck Your Budget
compatible with MongoDB Atlas
PlanetScale - MySQL That Actually Scales Without The Pain
Database Platform That Handles The Nightmare So You Don't Have To
These 4 Databases All Claim They Don't Suck
I Spent 3 Months Breaking Production With Turso, Neon, PlanetScale, and Xata
OpenAI Browser Implementation Challenges
Every developer question about actually using this thing in production
Cursor Enterprise Security Assessment - What CTOs Actually Need to Know
Real Security Analysis: Code in the Cloud, Risk on Your Network
Istio - Service Mesh That'll Make You Question Your Life Choices
The most complex way to connect microservices, but it actually works (eventually)
MySQL Replication - How to Keep Your Database Alive When Shit Goes Wrong
depends on MySQL Replication
MongoDB vs PostgreSQL vs MySQL: Which One Won't Ruin Your Weekend
depends on mysql
MySQL Alternatives That Don't Suck - A Migration Reality Check
Oracle's 2025 Licensing Squeeze and MySQL's Scaling Walls Are Forcing Your Hand
GitOps Integration Hell: Docker + Kubernetes + ArgoCD + Prometheus
How to Wire Together the Modern DevOps Stack Without Losing Your Sanity
MongoDB Alternatives: Choose the Right Database for Your Specific Use Case
Stop paying MongoDB tax. Choose a database that actually works for your use case.
Kafka + MongoDB + Kubernetes + Prometheus Integration - When Event Streams Break
When your event-driven services die and you're staring at green dashboards while everything burns, you need real observability - not the vendor promises that go
GitHub Desktop - Git with Training Wheels That Actually Work
Point-and-click your way through Git without memorizing 47 different commands
AI Coding Assistants 2025 Pricing Breakdown - What You'll Actually Pay
GitHub Copilot vs Cursor vs Claude Code vs Tabnine vs Amazon Q Developer: The Real Cost Analysis
I've Been Juggling Copilot, Cursor, and Windsurf for 8 Months
Here's What Actually Works (And What Doesn't)
What Enterprise Platform Pricing Actually Looks Like When the Sales Gloves Come Off
Vercel, Netlify, and Cloudflare Pages: The Real Costs Behind the Marketing Bullshit
MariaDB - What MySQL Should Have Been
Discover MariaDB, the powerful open-source alternative to MySQL. Learn why it was created, how to install it, and compare its benefits for your applications.
Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization