{
  "id": 15299051,
  "title": "Your SKIP LOCKED Queue Can Run a Job Twice. Heartbeats and Fencing Tokens Make It Safe",
  "url": "https://urgent.news/2026/10/17/your-skip-locked-queue-can-run-a-job-twice-heartbeats-and-fencing",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-17T23:02:06.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/gabrielanhaia/your-skip-locked-queue-can-run-a-job-twice-heartbeats-and-fencing-tokens-make-it-safe-34l4"
  },
  "original_language": "en",
  "account": "Your skip locked queue can run a job twice. Heartbeats and fencing tokens make it safe. Book: Event-Driven Architecture Pocket Guide. Think in Go series. Hermes IDE GitHub IDE for AI coding tools. xgabriel.com GitHub. Receipt job renders a PDF and emails it in 20 seconds. Worker leases job for 30 seconds. PDF service slow, job takes 45 seconds. Customer gets two receipts. Postgres misbehaving. Lease expired while work running. Tutorial builds queue in plain SQL plus Python worker. Triggers double run on purpose. Safe through heartbeat, fencing token, idempotency key. Everything runs against local Postgres in Docker. Queue: one table and one claim query. Start Postgres 18 Docker image. Create jobs and side_effects tables. Claim statement picks oldest job, bumps attempt, stamps new lease. Claim commits right away, row lock goes with it. Only lease_until shows job taken. Lease timestamp from now(), no clock drift. Keep transaction open and hold row lock for whole job, but locks connections and open transaction. If connection drops mid-job, lock released and another worker takes row. Double run reproduced. Install psycopg3, save as worker.py. Lease 3 seconds, job takes 10 seconds. Pretend to render PDF. Finish function updates status to done.",
  "summary": "Book: Event-Driven Architecture Pocket Guide Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub Say your receipt job renders a PDF and emails it. It usually takes 20 seconds, and the worker's lease on the…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}