SQL Job Queue

Use when building a DB-backed job queue / task scheduler on SQLAlchemy 2.x whose readiness is dependency-driven, whose jobs are long-running and stateful, and whose only durable substrate is the relational DB — single box, embeddable, no broker, multi-dialect (SQLite / PostgreSQL / MySQL). Covers the generic jobs/job_deps model, the ready-set query, the per-dialect atomic lease (FOR UPDATE SKIP LOCKED on PostgreSQL + MySQL 8 vs BEGIN IMMEDIATE on SQLite, with dialect detection), crash-resume via heartbeat + lease expiry + stale-lease reclaim, the hung-but-alive per-dispatch timeout, weighted fair-share over group_key, the scan→rank→lease→dispatch→persist→reclaim tick loop, polling vs LISTEN/NOTIFY wake, and the at-least-once idempotency contract. Keywords: job queue, task scheduler, ready-set, SKIP LOCKED, lease, crash-resume, multi-dialect, SQLAlchemy, background jobs. Sync-first. Not the SQLAlchemy data layer or locking primitive (sqlalchemy), not migrations (alembic).

bm629 e11ffce 3 files · 47.0 KB Updated

File contents

bm629/agent-skills/tree/main/skills/sql-job-queue commit e11ffce7f5

Frequently asked questions

npx skillmds@latest add bm629/sql-job-queue