Job queue stuck for two days: the case for leases over a two-state pending/done flag
Kodenstudio · reddit · 2026-10-14
A developer shares a two-day debugging lesson: his job queue had only two states, pending and done. When a worker crashed mid-job, nothing flipped the row, so the next worker picked up the same poisoned task and crashed again — the queue went silently dead while the dashboard looked healthy.
The fix was small: stop trusting the flag and give each job a lease — claim it, stamp an expiresat, send heartbeats while working, and let a simple reaper sweep expired leases back into the pool. "Two hours to build, two days to realize I needed it." He asks whether others run leases on top of a status column or skip the state machine entirely.
More from coding & agent
- Dev ships throwaway Postgres for agents: pg19 via pglite on Cloudflare DO over raw TCP — ritakozlov · 2026-11-29
- Product idea: cloud Android VMs and home WiFi proxies to make agents look human — Darpinian · 2026-11-29
- 38 free agent skills distilled from shipping three live AI products — PawelHuryn · 2026-11-29
- Step 5: run evals on synthetic data pre-launch, watch real traces after — PawelHuryn · 2026-11-29
- Break your agent before attackers do: 6 tests mapped to OWASP LLM Top 10 — PawelHuryn · 2026-11-29
- PM shares playbook for shipping 4 customer-facing Claude agents into production — PawelHuryn · 2026-11-29