What is Livelock?
The Hallway Problem
Two people walking toward each other in a narrow hallway. Person A steps left to let B pass. Person B steps right (their left) to let A pass. They are now still blocking each other. So A steps right. B steps left. Still blocked. They keep dancing but nobody moves forward.
Threads do exactly this. Thread 1 detects a conflict, backs off, retries. Thread 2 detects the same conflict, backs off, retries. Both keep backing off and retrying in sync. Nobody makes progress.
Why Livelock Is Tricky
CPU stays busy: Unlike deadlock where threads are blocked and use no CPU, livelock burns CPU cycles constantly. Your monitoring shows 100% utilization. Everything looks active.
Hard to detect: Health checks pass because threads are responding. Logs show activity. But throughput is zero. The system is running in circles.
Often caused by recovery code: Ironically, livelock frequently happens when you try to be too clever about avoiding deadlock. You add backoff logic that all threads follow identically.
Common Livelock Patterns
Identical retry logic: All threads use same backoff timing, retry at same moment.
Symmetric conflict resolution: Both threads use same rule like "give up your lock if someone else wants it" - so both give up simultaneously.
Overly polite protocols: Each thread tries too hard to accommodate others.