What happened
A schema migration on the primary database took a lock on the accounts table, which the API reads on every request. Requests queued behind the lock until they timed out, and about a third of them failed for 70 minutes.
Why it wasn't caught
The migration ran in seconds on staging, which has a fraction of production's rows. Nothing checked how long it would hold the lock.
What we're changing
- Migrations now run with a lock timeout and retry instead of waiting.
- Large tables are migrated in batches, outside peak hours.
- An alert fires when API error rates pass 5% for two minutes, not ten.