Basic Scenario
- Transaction A locks row 1 and waits for row 2.
- Transaction B locks row 2 and waits for row 1.
- Both transactions are now stuck, waiting for the other to release its lock.
MySQL’s InnoDB engine automatically detects deadlocks and resolves them by
rolling back one of the transactions, allowing the other to proceed.