Upgrading MySQL at Shopify
Shopify moved hundreds of horizontally sharded Percona Server shards, thousands of VMs in all, from 5.7.21 to 5.7.32, mainly to get writeset-based replication parallelism across replication topologies up to four hops deep. Rollback testing turned up a downgrade bug: metadata-only ALTER TABLE statements, such as the AUTO_INCREMENT reset in Shopify's startup script, triggered full table rebuilds. The cause was mismatched HA_PACK_KEY flags on InnoDB indexes, which two earlier upstream fixes in 5.7.23 and 5.7.27 had not fully resolved, and the team patched it in their internal fork. In parallel they extended Mason, their self-healing VM service, into a declarative per-shard topology reconciler that provisions upgraded replicas, with a priority lane for healing, queue throttling, feature flags and a dry-run mode.
Related posts
- Upgrading GitHub.com to MySQL 8.0
GitHub Engineering mediumAdeptGitHub upgraded 1200+ MySQL hosts (300+ TB, 5.5M QPS, 50+ clusters, including Vitess) from 5.7 to 8.0 over more than a year without breaking SLOs. The rollout went in stages: rolling replica upgrades per data center, then a replication topology with parallel 5.7 and 8.0 chains, then an Orchestrator graceful failover to an 8.0 primary, and finally cleanup after a 24-hour validation. Keeping rollback possible required backward replication from 8.0 to 5.7, which meant pinning utf8/utf8_unicode_ci collation and working around 8.0 role statements. Other problems included a commit-order replication hang fixed in 8.0.28, Vitess VTgate version advertising, and large WHERE IN queries that crashed MySQL in production despite passing CI.
- Migrating Facebook to MySQL 8.0
Meta Engineering mediumAdeptFacebook moved its MySQL fleet from a heavily customized 5.6 branch straight to 8.0, skipping 5.7. Over a couple of years the team evaluated more than 2,300 patches and ported about 1,500. Each replica set was moved independently by adding 8.0 secondaries via mysqldump, promoting them and then removing the 5.6 instances, with config-driven automation and per-replica-set rollback. Problems found along the way included utf8mb4_0900 collation mismatches, new reserved keywords like groups and rank, InnoDB deadlocks fixed by lowering isolation after standardizing on row-based replication, ACL cache and binlog index mutex contention, and higher memory use that required trimming performance_schema and InnoDB structures.
- Shard Balancing: Moving Shops Confidently with Zero-Downtime at Terabyte-scale
Shopify Engineering mediumAdeptShopify rebalances its MySQL shards by moving individual shops between pods online, with downtime confined to a brief cutover. Placement is decided by simulating proposed moves against historical utilization data, which in one case narrowed the spread between least- and most-used shards from about 4x to about 2x. The move itself uses Ghostferry, which batch-copies rows filtered by shop_id using SELECT...FOR UPDATE while tailing the row-based binlog to replay concurrent writes. Once replication lag is near real time, a Redis-backed multi-reader-single-writer lock halts writes for the shop so remaining binlog events can drain, after which the routing table is updated, the lock released, the move verified and stale data pruned from the source shard.
- Partitioning GitHub’s relational databases to handle scale
GitHub Engineering mediumAdeptGitHub split its monolithic `mysql1` MySQL cluster by first virtually partitioning tables into schema domains (declared in YAML) and enforcing boundaries with query and transaction linters, then physically moving domains to new clusters via Vitess vertical sharding or a custom ProxySQL/GTID-based write-cutover script. Cross-domain joins were eliminated with techniques like preload, Rails' new `disable_joins` option and application-side joins, validated with Scientist experiments. The write-cutover moved 130 of the busiest tables in tens of milliseconds with only a handful of failed writes. Query volume grew from 950k to 1.2M queries/s while average per-host load halved, reducing database-related incidents.
- Incident Report: September 22nd, 2025
Railway mediumAdeptA schema change removing an unused column was partially reverted by a later code change, breaking a core API and leaving Railway's project canvas stuck loading. After a 15-minute fix, the backlog of queued deployments flooded the Control Plane, whose PgBouncer pooler had been silently upgraded several versions when Railway moved off deprecated Bitnami images. The new version consumed abnormal CPU and memory under load, likely from a changed default configuration. Deployments were shed by tier and the database scaled up, but recovery came only after rolling PgBouncer back, which gave a 100x performance improvement. Follow-ups include CI schema compatibility checks, PgBouncer metrics alerting, phased pooler upgrades, and moving Control Plane storage off Postgres.