Troubleshooting·MySQL
MySQL Locks, Blocking and Deadlocks
One transaction holds a row lock, another waits and dies with `ERROR 1205`. Then two transactions take the same rows in opposite order and InnoDB kills one with `ERROR 1213` - and its report names both, the rows and the index.
Performance Guide 35 of 45 Advanced
- OSUbuntu 26.04 LTS (resolute)
- MySQL8.4.10-0ubuntu0.26.04.1
- Test data400,000 rows, 2 core / 4 GB host
- TimeAbout 19 min
- Reviewed27 August 2026
Written against the versions above. REPEATABLE READ is the MySQL default and is stricter than most databases' READ COMMITTED default. It holds more locks for longer, which makes both failures here more likely than on PostgreSQL or Oracle.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- The
customerstable. - Two concurrent connections - the transcript backgrounds them with
&.
-
Read the three settings that govern all of it
-
Block one transaction behind another
-
Find out who is blocking whom, while it is happening
-
Cause a real deadlock
-
Read InnoDB's own account of it
Official sources
- MySQL 8.4 Reference Manual - Optimizing Queries with EXPLAIN
- MySQL 8.4 Reference Manual - Obtaining Execution Plan Information
- MySQL 8.4 Reference Manual - Multiple-Column Indexes
- MySQL 8.4 Reference Manual - Skip Scan Range Access
- MySQL 8.4 Reference Manual - The Slow Query Log
- MySQL 8.4 Reference Manual - InnoDB Locking