pub async fn reap_startup_claims(
conn: &DatabaseConnection,
queues: &[String],
) -> Result<u64, Error>Expand description
Park leftover claimed rows on queues as failed at worker startup.
Closes the orphan-claim window that the visibility-timeout reaper leaves
open: when a worker is killed mid-job (SIGKILL from a deploy restart, OOM),
its claimed rows stay claimed until visibility_timeout elapses
(default 300s). Consumers reading jobs.status see those rows as Active
for the full timeout window — UI labels like “in progress” stick until the
row is reaped or manually cleared.
Called once per WorkerLoop::run before the claim loop starts. Operates
only on the queues this worker handles, so concurrent workers on disjoint
queues never clobber each other. Assumes the single-worker-per-queue model
the rest of the worker is built around — multi-worker-per-queue setups
should rely on visibility_timeout instead.
Returns the number of rows reaped.