← Home ← Codex ← DEBT ← Engine
Browse by Category
+ added · updated 7d
← Back to glossary

Starvation & Livelock

Concurrency Intermediate
debt(d9/e5/b5/t7)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9). The detection_hints field explicitly states 'automated: no', and the code_pattern (while.*retry|sleep.*retry) only hints at the structure, not the pathological timing interaction. Starvation and livelock manifest only under specific load conditions or timing coincidences in production; no standard linter or SAST tool catches the logical failure.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix calls for adding exponential backoff with jitter, setting maximum retry counts, and switching to fair queues — changes that typically span multiple services, queue configurations, and retry-loop call sites rather than a single-line patch. It's not a full architectural rework but clearly more than a parameterised one-liner.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). The applies_to covers web, cli, and queue-worker contexts, meaning retry and scheduling logic across all three contexts must be designed with jitter and fairness in mind. Every new retry loop or queue consumer added to the codebase inherits this concern, imposing an ongoing tax without necessarily reshaping the whole architecture.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap (contradicts how a similar concept works elsewhere)' (t7). The misconception field states developers believe livelock is rare, when in fact it emerges commonly in distributed retry logic when two services conflict at fixed intervals — a scenario that is extremely common in microservice architectures. Fixed retry intervals look obviously correct (simpler code, predictable timing) but are precisely the cause of the problem, making the 'obvious' implementation the wrong one.

About DEBT scoring →

TL;DR

Starvation: a thread never gets resources because others monopolise them. Livelock: threads actively respond to each other but make no progress — like two people stepping aside for each other indefinitely.

Explanation

Starvation: a low-priority thread waits indefinitely while high-priority threads keep acquiring the resource. Solutions: fair scheduling, priority ageing (priority increases with wait time), FIFO queues for lock acquisition. Livelock: threads are not blocked but actively change state in response to each other — making no net progress. Classic: two processes each detect conflict and back off simultaneously, then retry simultaneously, indefinitely. Solutions: randomised back-off (exponential backoff with jitter), coordinator, timeout with fallback. Livelock is harder to detect than deadlock — CPU is busy but work is not progressing.

Common Misconception

Livelock is rare — it appears in distributed systems retry logic when two services conflict and both retry at the same interval. Jitter in retry intervals prevents it.

Why It Matters

Starvation starves legitimate requests indefinitely; livelock wastes CPU without making progress — both can make a service appear alive but non-functional.

Common Mistakes

  • Fixed retry interval — causes convoy/thundering herd that can create livelock.
  • No priority ageing — low-priority jobs wait forever under load.
  • Not adding jitter to retry backoff.

Code Examples

✗ Vulnerable
// Fixed interval retry — livelock risk:
while (!acquireLock()) {
    sleep(1); // Both workers retry at same time indefinitely
}
✓ Fixed
// Exponential backoff with jitter:
$attempt = 0;
while (!acquireLock()) {
    $delay = min(30, (2 ** $attempt)) + rand(0, 1000) / 1000; // Jitter
    sleep($delay);
    if (++$attempt > 10) throw new LockTimeoutException();
}

Added 23 Mar 2026
Views 126
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 1 ping T 2 pings F 0 pings S 1 ping S 0 pings M 0 pings T 1 ping W 1 ping T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T
No pings yet today
PetalBot 1
Amazonbot 10 Google 10 Ahrefs 9 SEMrush 9 Bing 7 Perplexity 5 Scrapy 5 Unknown AI 4 PetalBot 4 Meta AI 3 ChatGPT 2 Twitter/X 2 Applebot 2 Sogou 2 Brave Search 1 Baidu 1
crawler 72 crawler_json 3 pre-tracking 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Add exponential backoff with random jitter to all retry loops. Set maximum retry count. Use fair queues for lock acquisition.
📦 Applies To
web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
while.*retry|sleep.*retry
Auto-detectable: ✗ No
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: Function


✓ schema.org compliant