tinybus/ live
connecting…
a postgres-backed job queue. click a button —
watch a row move through the table
as SELECT … FOR UPDATE SKIP LOCKED hands it to a worker.
queue state
no queues yet — enqueue something below.
activity
- waiting for events…
controls
the query
-- what runs every time a worker claims a job
WITH next AS (
SELECT id FROM jobs
WHERE queue = $1
AND locked_at IS NULL
AND dead_at IS NULL
AND run_at <= now()
ORDER BY run_at
FOR UPDATE SKIP LOCKED
LIMIT 1
)
UPDATE jobs
SET locked_at = now(),
locked_by = $2,
attempts = attempts + 1
WHERE id = (SELECT id FROM next)
RETURNING id, queue, payload, attempts, max_attempts,
created_at, run_at;
two workers compete for the same row. one wins. the other skips and takes the next. no broker. no race. one round-trip.