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.

Original post →

More from coding & agent

coding & agent channel →