Repository navigation
v1.5.0
PgQueuer v1.5.0
pgq upgrade now reads the installed schema and applies only what that database is missing (ADR-0016). A current database runs nothing.
Why
Up to v1.4.0, PgQueuer described its schema twice: an install script, and an upgrade script of idempotent statements that ran in full on every upgrade. Nothing compared the two, and they drifted. Upgrade created an index that install never did, and a database from v0.18 came out with log aggregation broken. Every upgrade also rewrote pgqueuer_statistics, needed or not.
Now one declared schema is the source of truth. Install renders it; upgrade compares it with the catalog and runs the difference. Install and upgrade can no longer disagree, and a database from any earlier release ends up with the same schema.
What's new
pgq upgrade --planprints the statements and notes for this database and applies nothing.pgq stale,pgq workersandpgq backlogshow picked jobs with an old heartbeat, workers holding jobs, and the queued backlog per entrypoint.--jsonon those and onpgq failedmakes the output usable from scripts and coding agents.- An agent guide for coding agents helping someone set up or troubleshoot PgQueuer.
- Workers flush heartbeats every eighth of
heartbeat_timeoutinstead of every quarter. With latency under 0.2 of the timeout, one failed heartbeat write no longer lets a worker re-pick a running job. That is about twice as many batchedUPDATEs; rows written per job are unchanged.
Upgrade
Preview, then apply, before starting 1.5.0 workers:
pgq upgrade --plan # statements and notes, nothing applied
pgq upgradepgq upgrade prints its note: lines only after it has applied, so read them from --plan.
A database coming from v1.4.0 gets:
ALTER TABLE pgqueuer_statistics ALTER COLUMN created SET DEFAULT date_trunc('sec', now()). Catalog only; stored rows are unchanged.- On PostgreSQL 14+, a one-time rebuild of
pgqueuer_statistics_unique_count. The new index is built beside the old one, but the build holds aSHARElock that blocks writes topgqueuer_statistics; on a large table, run it in a quiet window. - If it ever ran
pgq upgrade, a drop of the retiredpgqueuer_heartbeat_id_id1_idx.
If you apply pgq sql upgrade yourself instead: the script drops and recreates the notify trigger on every apply, and on PostgreSQL 14+ its first apply drops the statistics unique index before rebuilding it. Run it in a quiet window.
Fixes
- Upgrading a v0.18 database leaves log aggregation working. v1.4.0 left the pre-v0.19 statistics index and
NOT NULLontime_in_queuein place. - A worker no longer starts a second copy of a job it is still running when that job's heartbeat reaches the database late.
enqueue()rejects batch lists of different lengths instead of padding the short one withNULL.AsyncpgPoolDriveraccepts a one-connection pool.- With
PGQUEUER_SCHEMAset, the dashboard reads that schema's tables.
Notes
pgq upgradeprintsApplied N statements.orPgQueuer schema is already up to date.instead ofUpgraded PgQueuer schema.enqueue(["a", "b"], None, [0, 0])now raisesValueError. Pass one value per job, e.g.[None, None].- A column type the planner can't convert stops
pgq upgradewith exit code1. v1.4.0 ignored it. pgq upgrade --durabilityis hidden, warns, and is ignored. It will be removed in v2.0; usepgq durability.- The upgrade advisory lock is not held through
AsyncpgPoolDriver. RunQueries.upgrade()on a single connection, aspgq upgradedoes.
Everything else, including removed internals, new Queries methods and MCP output types, is in RELEASE.md.
Thanks to new contributors!
- @lux-liang made their first contribution in #830
- @mvanhorn made their first contribution in #852
- @bensynapse made their first contribution in #872
Full Changelog: v1.4.0...v1.5.0
Full Changelog: v1.4.0...v1.5.0