
8/14/2024
What this post added
This post details how Shopify mitigated deadlocks in high concurrency environments by introducing composite primary keys in MySQL. By changing the primary key to include the `account` column alongside the existing `id`, data is physically ordered on disk by account, compartmentalizing gap locks required by concurrent processes and preventing overlaps that caused deadlocks. This solution was implemented at the database layer without application logic changes, significantly increasing import job throughput.