Skip to content

12.40.0

Latest

Choose a tag to compare

@timgit timgit released this 25 Nov 21:35
· 8 commits to master since this release

Schema version: 48. The migration adds a nullable column to the queue table and rewrites no rows.

  • pauseQueue() and resumeQueue() stop and restart fetching from a queue.
  • Scheduled jobs are created without the send-it worker. cronWorkerIntervalSeconds is deprecated.
  • After an outage, missed: 'once' sends one job instead of up to two.
  • A worker retries a completion or failure that loses its database connection.
  • drain() goes on to the children of a flow parent it completes.
  • getWarnings() reads persisted warnings.
  • CLI commands report a failed connection as an error and exit 1.

Pausing a queue

pauseQueue(name) stops fetching from a queue. resumeQueue(name) starts it again and wakes the queue's workers on this instance, or on every instance when the queue has notify on. Sends, schedules and active jobs carry on while the queue is paused. getQueue() and getQueues() report paused and pausedOn. Thanks to @MoazEmad1 for #1018, which closes #551.

While a paused queue holds jobs, the monitor emits a queue_paused warning, at most once an hour on each instance.

Scheduled jobs without the send-it worker

The schedule check now creates scheduled jobs itself, without the internal __pgboss__send-it worker. Jobs no longer wait up to 5 seconds for that worker, and instances no longer run its 5-second poll. cronWorkerIntervalSeconds does nothing and emits a DeprecationWarning (PGBOSS_DEP_CRON_WORKER_INTERVAL). It will be rejected in the next major.

This also lifts a limit on large deployments. The send-it worker forwarded jobs in batches every 5 seconds, and a deployment with several hundred minute schedules created jobs faster than it forwarded them. Those jobs fell further behind every minute.

Two behaviors change with it:

  • A schedule sends jobs only for occurrences after it was stored, or after its expression, time zone or precision last changed. A * * * * * schedule stored at 12:00:30 sends its first job for 12:01, where 12.39.0 sent one for 12:00. Storing the same definition again, as a deployment does on every boot, changes nothing.
  • Under missed: 'once', the first schedule check after an outage sends one job, for the latest occurrence since the outage began. 12.39.0 sent one for the latest missed occurrence and another for the occurrence due at that check.

Other changes

  • getWarnings({ type, limit, after }) returns the warnings written to the warning table when the persistWarnings option is set, newest first. Pass the last warning's id as after for the next page. Until now they were read only by the dashboard or with SQL. Thanks to @blue2cat for raising it in #841.

  • A worker whose complete() or fail() loses its database connection runs it again, up to two more times, before it fails the batch. Each run is limited to the attempt the worker fetched. A statement that landed before the drop therefore doesn't settle the job twice. A transactional worker's completion is not run again, since the handler's writes were on the connection that dropped.

  • drain() releases the children of a flow parent it completes, and goes on to them. A child whose parent failed or was cancelled stays blocked.

  • pg-boss pins cron-parser to 5.10.6. An upcoming behavior change in cron-parser would drop some scheduled jobs in the hour the clocks repeat when they go back. A later pg-boss release lifts the pin once it handles the change.

  • Fix: CLI commands report a failed connection or a missing permission as an error and exit 1. They used to report pg-boss as not installed. version and rollback exited 0 in that case, and a script that checks their exit code sees the change. Thanks to @lokeshkonka for #1020.

  • Fix: the published type declarations no longer import pg. A TypeScript project with skipLibCheck: false and no @types/pg failed to compile against 12.39.0. Thanks to @sebdanielsson for #1019.

  • Fix: a second instance started with the same TestClock on the same schema shares the clock's table. On CockroachDB, its start() used to fail.

  • Fix: update() and upsert() reject a negative deleteAfterSeconds, as send() does. A deleteAfterSeconds key set to undefined is rejected too. Thanks to @SelmanBoray for #1017.

Upgrading

Instances on 12.39.0 and 12.40.0 can run side by side during a rolling upgrade. A 12.39.0 instance doesn't read a pause and keeps fetching from a paused queue. Pause a queue once every instance runs 12.40.0. A 12.40.0 instance skips an occurrence a 12.39.0 instance has already queued on send-it, forwards any it left behind, and leaves a completed send-it row for each occurrence it sends, which keeps an older instance from queuing it again. The send-it queue stays until the next major. An upgrade from a release before 12.31.0 can still send an occurrence twice while both releases run.

PRs