Zero Labs
Industry News / AI

How GitHub Upgraded 1,200 MySQL Hosts Without Dropping a Single Query

Source · Towards AI By TechLogStack

From the publisher’s feed, collected in the ZeroLabs newsroom.

The year-long plan to migrate 300 terabytes of data and 5.5 million queries per second off an end-of-life database — without a single maintenance window.MySQL 5.7 was hitting end-of-life, and GitHub’s production database fleet spanned 1,200 hosts, 300 terabytes of data, and 5.5 million queries every second. Getting from here to MySQL 8.0 without disrupting 100 million developers was going to take more than a weekend. It took more than a year — and the most important engineering decision wasn’t about the upgrade itself. It was about how to undo it.Part 1: The Problem With Upgrading 300 TerabytesMySQL is not a peripheral system at GitHub. It is the foundation.Every repository, every pull request, every issue, every code review comment, every user account, every line of billing data for 100 million developers — all of it lives in MySQL. When Oracle announced MySQL 5.7 end-of-life for October 2023, GitHub’s database team had one decision to make: stop receiving security patches on the database that holds every line of code pushed to GitHub, or upgrade.The scale of what an upgrade meant:1,200+ MySQL hosts across Azure VMs and bare-metal data center hardware300+ TB of relational data stored across 50+ independent clusters5.5 million queries per second — the SLO target that could not slipOver a year of planning and execution before the final host was promotedGitHub’s fleet is not one database. It is 50+ independent clusters, each serving a specific product domain — repositories, issues, pull requests, billing, the social graph. Each cluster has its own primary-replica topology. The upgrade had to be executed independently, cluster by cluster, each following the same playbook, each with a rollback path preserved until the very end.The preparation phase began in July 2022 — a full year before a single production host was promoted. The team ran MySQL 5.7 and 8.0 side-by-side in CI for every application, built MySQL 8.0 debug containers for developers to test queries against, and tracked every cluster’s upgrade status on a dedicated GitHub Projects board. All of this happened before touching production.Then, during staging tests, they found something that threatened to break the entire migration.Part 2: The Hidden Breaking Change — and How They Solved ItMySQL 8.0 changes its default collation to utf8mb4_0900_ai_ci — a Unicode 9.0 specification that MySQL 5.7 simply does not support.This mattered because GitHub’s rollback strategy depended on backward replication. The plan was: promote an 8.0 host to primary, but keep 5.7 standbys warm and synchronized so that if anything went wrong, a 5.7 host could be promoted back instantly. But when GitHub tested this in staging, promoting an 8.0 primary caused replication to break on all downstream 5.7 replicas immediately. The collation metadata in the binary log was unreadable by 5.7’s replication parser.There was a second problem. MySQL 8.0’s new ROLE management syntax generated statements in the binary log that 5.7 replicas could not execute. Two breaking changes. Both had to be fixed before any production promotion could proceed.Here is the exact fix from the upgrade:-- MySQL 8.0 defaults to utf8mb4_0900_ai_ci (Unicode 9.0)-- MySQL 5.7 only supports up to utf8mb4_unicode_520_ci-- Fix: explicitly set database/table collations to a 5.7-compatible value-- On the 8.0 primary, before promotion:ALTER DATABASE github_production CHARACTER SET utf8 COLLATE utf8_unicode_ci; -- 5.7-compatible collation-- Verify new tables inherit the correct collationSHOW CREATE TABLE repositories\G-- Should show utf8_unicode_ci, NOT utf8mb4_0900_ai_ci-- Confirm replication is running on downstream 5.7 replicasSHOW SLAVE STATUS\G-- Expected: Seconds_Behind_Master: 0-- Slave_SQL_Running: Yes-- Last_Error: (empty)-- The roles fix: temporarily strip role-expansion from permission grants-- during the upgrade window so no ROLE syntax appears in the binlogWith both fixes validated in staging, the team built the five-step upgrade playbook — one that preserved rollback availability at every single step:Step 1 — Upgrade replicas one data center at a time, route read traffic to 8.0 replicas. Rollback: disable 8.0 replicas, re-enable 5.7.Step 2 — Reconfigure topology: split into dual 8.0 and 5.7 replication chains running in parallel. Rollback: fail back to 5.7 chain.Step 3 — Promote 8.0 replica to primary via Orchestrator graceful failover. Rollback: 5.7 chain still in sync.Step 4 — Monitor for 24 hours of complete traffic cycle at full load. Rollback: promote 5.7 standby if needed.Step 5 — Decommission 5.7 standbys after 24-hour success confirmation. Rollback: window closed.The 24-hour validation window was not arbitrary. GitHub’s traffic has strong diurnal patterns — dramatically different load profiles between business-hours peaks and overnight lows. A cluster that looked healthy at 2am might reveal latency regressions when developers in Europe and North America opened pull requests the next morning. The 24-hour window caught several edge cases in early clusters before the team moved to the next one.“Upgrading the fleet with no impact to our Service Level Objectives was no small feat — planning, testing and the upgrade itself took over a year and collaboration across multiple teams within GitHub.” — Jiaqi Liu, Daniel Rogart, Xin Wu, GitHub Engineering BlogPart 3: The Architecture That Made Zero-Downtime PossibleGitHub’s upgrade didn’t just rely on a good playbook. It relied on a tooling ecosystem built specifically for this class of problem.During the promotion window — both 8.0 and 5.7 chains run in parallel, rollback available until 24-hour validation completesFour tools made the year-long upgrade possible without a single maintenance window:Orchestrator — manages replication topology and automated failover. During the upgrade, all 5.7 hosts were explicitly blacklisted as failover candidates. Without this, an unplanned primary failure could have caused Orchestrator to automatically promote a 5.7 standby — undoing hours of work without anyone pressing a button.gh-ost — applies schema changes to production tables without locking them. Critical for a 300+ TB fleet where a traditional ALTER TABLE could take hours and block millions of queries.freno — throttles schema migration speed based on replica lag, preventing migrations from disrupting production reads during the upgrade window.Percona Toolkit — provides checksumming and replication verification between 5.7 and 8.0 chains.The final state — 8.0 primary replicating to 8.0 replicas across all data centers, Orchestrator monitoring for failoverThe Vitess complication added one more coordination step. GitHub’s highest-traffic clusters are horizontally sharded via Vitess. Its proxy component, VTgate, advertises the MySQL version to client applications. One Java client used that advertised version to decide whether to disable the MySQL query cache — a feature completely removed in 8.0. The moment even one shard in a Vitess keyspace was upgraded, VTgate’s version advertisement had to be updated simultaneously. Timing that bump to the exact moment of the first shard promotion became a critical coordination step with its own checklist item.The tooling ecosystem is what separated this upgrade from requiring dozens of maintenance windows. Without it, the answer to “how do you upgrade 1,200 hosts without downtime” would have simply been: you don’t.Part 4: What Every Engineer Should Take AwayGitHub’s MySQL 8.0 upgrade is one of the cleanest examples of large-scale infrastructure migration executed with real discipline. The lessons here are as much about process as they are about database mechanics.1. Design for rollback before you design for progress. GitHub’s entire strategy was architected around one constraint: rollback must be available at every step until the 24-hour validation window closed. The dual replication chains, the Orchestrator blacklist, the parallel standby maintenance — all overhead deliberately accepted to preserve the ability to undo. That safety margin is what made confident execution possible.2. Test reverse replication in staging — not just forward replication. The collation and ROLE incompatibilities were found in staging, which is exactly the right time. A breaking change discovered during a production promotion at 5.5M QPS is an incident. The same discovery in staging is a fix.3. A 24-hour traffic cycle is the minimum validation window. A cluster that passes health checks at 2am is not a validated cluster. GitHub’s diurnal traffic pattern meant peak-hour behavior was only observable during business hours the next day. Don’t close your escape hatch until you’ve seen the full traffic profile.4. Build upgrade automation as a library, not a one-time script. Every tool, template, playbook, and checklist from this project was built to be reusable. When MySQL 9.0 needs to be adopted, the playbook already exists. A year of effort becomes infrastructure that compounds in value with every future upgrade.5. Automation can work against you — constrain it explicitly. Orchestrator is designed to promote a healthy replica when a primary fails. During an upgrade, that helpful automation could have promoted a 5.7 standby, silently undoing hours of work. Any automated system that could reverse your migration must be explicitly told not to. Never assume automation understands a maintenance window.MySQL 5.7’s end-of-life was the forcing function that gave this project the organizational priority it needed. Security patch cutoffs are one of the most effective levers for getting infrastructure migrations approved and resourced. If your team has been deferring a major version upgrade — check when your current version’s security support ends. It may already be overdue.Engineering GlossaryBinary log — The sequential log of all data-modifying SQL statements that MySQL writes to enable replication and point-in-time recovery.CI (Continuous Integration) — The automated system that runs tests against every code change before it merges, ensuring the codebase is always in a shippable state.Codespaces — GitHub’s cloud development environment that spins up isolated VM workspaces for debugging, allowing engineers to test against specific MySQL versions without affecting production.Collation — A set of rules that determines how character strings are compared and sorted; different collations can produce different sort orders for the same strings.MySQL 5.7 — The production MySQL version GitHub had been running for years, which Oracle officially declared end-of-life in October 2023, meaning no more security patches or bug fixes.Orchestrator — An open-source MySQL high-availability tool co-created by GitHub that manages replication topology and automated failover.Replication topology — The tree of primary and replica MySQL hosts through which write changes propagate — the primary receives writes and replicas receive a stream of changes to stay in sync.utf8mb4_0900_ai_ci collation — A Unicode 9.0 character sorting specification supported in MySQL 8.0 but absent from 5.7, causing replication to break when an 8.0 primary writes to a 5.7 replica.Vitess — YouTube’s open-source MySQL sharding layer that GitHub uses for its highest-traffic product domains.VTgate — Vitess’s query router that intercepts MySQL connections and directs them to the correct shard.Read the full technical deep-dive — including GitHub’s interactive replication topology diagrams, the complete 5-step playbook, and source links: techlogstack.com/explore/github-mysql-8-upgrade-2023Follow TechLogStack on Medium for one real engineering breakdown per week — in plain English, the way your smartest friend would explain it.How GitHub Upgraded 1,200 MySQL Hosts Without Dropping a Single Query was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.