- Layer
- 3. The Database Depths
- Type
- Layer Boss
- Uptime
- 450 per head
- Latency
- ∞ (each head is waiting for the other)
- Threat Level
- ★★★★☆
Lore
The Deadlock Hydra has two heads, and both are extremely polite. The left head holds the orders table and won’t let go until the right head releases inventory. The right head holds inventory and won’t let go until the left head releases orders. “After you,” says one. “No, after you,” says the other. They have been saying this since 2019. Meanwhile, every request in the Realm queues up behind them.
How to defeat it
Kill one transaction so the other can finish. Sever one head and the other immediately completes its work and wanders off, satisfied.
Real-world tip: A deadlock happens when two database transactions each lock something the other needs, so neither can continue. MySQL usually detects this and cancels one of them automatically, and the app should simply retry it. Frequent deadlocks point to code that locks tables in different orders or holds transactions open too long. Keeping transactions short and always locking in the same order prevents most of them.
