---
title: "Upgrading MySQL at Shopify"
description: "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."
url: "https://swe.quest/articles/upgrading-mysql-at-shopify-bb0f87b54fe985d5"
canonical: "https://shopify.engineering/upgrading-mysql-shopify"
source: "Shopify Engineering"
published: "2021-12-02"
difficulty: "hard"
kind: "Case study"
reading_minutes: 16
tags: ["mysql","replication","debugging","deployment","cloud"]
---

# Upgrading MySQL at Shopify

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2021-12-02, 16 min read, Case study. Original: [https://shopify.engineering/upgrading-mysql-shopify](https://shopify.engineering/upgrading-mysql-shopify)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [MySQL](https://swe.quest/tags/mysql.md) (Data & databases)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)

## Prerequisites

- MySQL replication ([easy posts on MySQL](https://swe.quest/tags/mysql.md?difficulty=easy))
- InnoDB indexes
- ALTER TABLE algorithms ([easy posts on Algorithms](https://swe.quest/tags/algorithms.md?difficulty=easy))
- Chef provisioning

## Keywords

Percona Server, MySQL 5.7, Mason, Chef, Google Compute Engine, mysql\_upgrade, GDB

## Related posts

- [Upgrading GitHub.com to MySQL 8.0](https://swe.quest/articles/upgrading-github-com-to-mysql-8-0-2c7892d15b6d7ff3.md): GitHub Engineering · 2023-12-07 · Medium · 11 min read · MySQL, Replication, Deployment, Databases
  GitHub 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.
- [Migrating Facebook to MySQL 8.0](https://swe.quest/articles/migrating-facebook-to-mysql-8-0-5af9e565f1e50eea.md): Meta Engineering · 2021-07-22 · Medium · 11 min read · MySQL, Schema migrations, Replication, Refactoring & migrations, Testing
  Facebook moved its MySQL fleet from a heavily customized 5.6 branch straight to 8.0, skipping 5.7.
- [Shard Balancing: Moving Shops Confidently with Zero-Downtime at Terabyte-scale](https://swe.quest/articles/shard-balancing-moving-shops-confidently-with-zero-downtime-at-terabyte-scale-76a6177fa357eea4.md): Shopify Engineering · 2021-09-24 · Medium · 13 min read · MySQL, Distributed databases, Schema migrations, Scaling
  Shopify rebalances its MySQL shards by moving individual shops between pods online, with downtime confined to a brief cutover.
- [Partitioning GitHub’s relational databases to handle scale](https://swe.quest/articles/partitioning-github-s-relational-databases-to-handle-scale-7b5ea75acfc088c0.md): GitHub Engineering · 2021-09-27 · Medium · 9 min read · MySQL, Distributed databases, Scaling, Schema migrations, Ruby
  GitHub 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.
- [Incident Report: September 22nd, 2025](https://swe.quest/articles/incident-report-september-22nd-2025-f36fdb64699f52a7.md): Railway · 2025-09-22 · Medium · 5 min read · Incidents & postmortems, PostgreSQL, Schema migrations, Resilience, Deployment
  A 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
