MySQL Deadlock Analysis: GAP Locks, Phantom Reads, and How to Resolve Them
This article examines why concurrent upsert operations in a high‑throughput MySQL service can cause deadlocks due to GAP locks and phantom reads, explains the underlying InnoDB locking mechanisms, and offers practical solutions such as adjusting isolation levels or redesigning data sharding logic.
