1 day ago · 19 min read3830 words · Tech · hide · 0 comments

A queue pickup that ignored its limit, a plan cached while the table slept, and a consumer that deadlocked on its own success. The System, Briefly A staged pipeline processes events; each stage has a consumer composed of a fetcher goroutine and N = 10 workers per replica, two replicas per stage. Tasks live in a Postgres table, and a task’s stage is a column. A consumer picks up tasks by leasing them: UPDATE tasks SET picked_at = now() + $window, attempts = attempts + 1 WHERE id IN ( SELECT id FROM tasks WHERE state = $state AND deferred = 'no' AND attempts <= $max AND (picked_at IS NULL OR picked_at <= now()) FOR UPDATE SKIP LOCKED LIMIT $n) RETURNING *; After the UPDATE, the consumer takes a Redis lock per task, commits, publishes a notification per task on the event bus, and starts one goroutine per task that renews the lease and the lock every $window/3 until the task is released. Handlers advance the task to the next stage. If a consumer dies, leases lapse and another replica…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.