Skip to content

v1.5.0

Choose a tag to compare

@janbjorge janbjorge released this 04 Oct 20:16
· 234 commits to main since this release
603c907

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 --plan prints the statements and notes for this database and applies nothing.
  • pgq stale, pgq workers and pgq backlog show picked jobs with an old heartbeat, workers holding jobs, and the queued backlog per entrypoint. --json on those and on pgq failed makes 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_timeout instead 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 batched UPDATEs; 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 upgrade

pgq 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 a SHARE lock that blocks writes to pgqueuer_statistics; on a large table, run it in a quiet window.
  • If it ever ran pgq upgrade, a drop of the retired pgqueuer_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 NULL on time_in_queue in 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 with NULL.
  • AsyncpgPoolDriver accepts a one-connection pool.
  • With PGQUEUER_SCHEMA set, the dashboard reads that schema's tables.

Notes

  • pgq upgrade prints Applied N statements. or PgQueuer schema is already up to date. instead of Upgraded PgQueuer schema.
  • enqueue(["a", "b"], None, [0, 0]) now raises ValueError. Pass one value per job, e.g. [None, None].
  • A column type the planner can't convert stops pgq upgrade with exit code 1. v1.4.0 ignored it.
  • pgq upgrade --durability is hidden, warns, and is ignored. It will be removed in v2.0; use pgq durability.
  • The upgrade advisory lock is not held through AsyncpgPoolDriver. Run Queries.upgrade() on a single connection, as pgq upgrade does.

Everything else, including removed internals, new Queries methods and MCP output types, is in RELEASE.md.

Thanks to new contributors!

Full Changelog: v1.4.0...v1.5.0

Full Changelog: v1.4.0...v1.5.0