Skip to content

v0.17.0

Choose a tag to compare

@kvet kvet released this 05 Nov 17:22
· 107 commits to main since this release
v0.17.0
d24f69e

What's Changed

Queuert 0.17 moves job completion into your own database transactions and replaces per-job attempt leases with a worker registry, so ownership is fenced end to end. It also batches acquisition and notifications to cut database and broker round trips. This is a breaking release: read the migration notes before upgrading, and run the 002_worker_liveness migration.

Breaking Changes

  • Jobs complete inside your own transaction. The handler calls complete({ ...txCtx, transactionHooks, output | continueWith | reschedule }) inside a transaction it opens. prepare, step, the old complete callback, and the atomic/staged processing modes are removed. AttemptMiddleware keeps only wrapHandler. A handler that returns without a committed complete is rescheduled with backoff.
  • Worker registry with per-worker leases.
    • Workers register in a new worker table and hold a lease configured by leaseConfig { durationMs, heartbeatMs } (defaults 60s / 15s).
    • Attempt tokens fence stale writes. Jobs of expired workers are reclaimed as failed attempts with JobAttemptReclaimedError.
    • workerName is now workerId.
    • attemptConfig, defaults, InProcessWorkerDefaults, Job.attemptUntil and RetryConfig are removed in favor of a top-level backoffConfig.
    • New errors: WorkerAlreadyLiveError, WorkerLeaseLostError, InvalidWorkerIdError.
  • New 002_worker_liveness migration for @queuert/postgres and @queuert/sqlite. It returns running jobs to pending, and Postgres gives up after 5s if it cannot take its locks. Jobs claimed by pre-0.17 workers are reclaimed during a rolling upgrade.
  • The attempt signal is a plain AbortSignal. JobAbortReason and TypedAbortSignal are removed.
  • One jobAttemptLost event for every attempt loss. It replaces jobAttemptTakenByAnotherWorker and jobAttemptAlreadyCompleted. jobAttemptExtended, jobAttemptExpired and workerStopping are removed.
  • Mutating client methods reject contexts that are not open transactions. State providers must implement isTransaction.
  • stateAdapter.config adds the maxBlockersPerJob and countCap options. Job IDs are now generated and validated in core.
  • Batched acquisition: startJobAttempt is now startJobAttempts(limit).
  • Batched notify adapters for @queuert/postgres, @queuert/redis and @queuert/nats. Wake hints are removed. PgNotifyProvider.publish takes messages[], and RedisNotifyProvider.publish is removed.
  • NATS now uses the @nats-io/nats-core ^3 peer dependency instead of nats, and the kv option is removed.
  • Renames:
    • listChainTypeNames / listJobTypeNames → getChainTypeNames / getJobTypeNames
    • countByChainTypeNames / countByJobTypeNames → countChainsByTypeName / countJobsByTypeName
    • generateId / validateId / idType → generateJobId / validateJobId / jobIdType
  • The one-step v0.15.1 upgrade path is removed from @queuert/postgres and @queuert/sqlite.
  • OpenTelemetry (@queuert/otel):
    • queuert.worker.id is removed from metric attributes.
    • Each attempt is one span; the prepare, step and complete child spans are gone.
    • queuert.job.attempt.lost replaces the taken-by-another-worker and already-completed counters. The extended, expired and worker-stopping counters are removed.
    • New queuert.worker.lease_lost counter.

Features

  • fence({ ...txCtx }) checks attempt ownership inside other transactions the handler opens.
  • Client read API for workers: getWorker, getWorkers, countWorkers, countWorkersByTypeName, countRunningJobsByWorkerId, listWorkers, listWorkerJobs.
  • Blockers can be passed by ID ({ id, typeName? }).
  • pickProcessors / omitProcessors, with a compile-time check for overlapping processors.
  • New workerIdType option for the Postgres and SQLite state adapters.
  • Dashboard:
    • Workers pages and worker links, with warnings for lost leases and for job types that have no live worker.
    • Types can be filtered by status, and the find dialog finds types with fzf-style matching.
    • Restyled, with the version shown in the top bar.

Bug Fixes

  • Schedule, reschedule, timeout and awaitChain delays beyond 2^31-1 ms (about 24.8 days) now work. On Postgres the worker no longer fails when the nearest scheduled job is that far away (#5, #6).
  • Recovery backoff resets after the worker recovers.
  • Concurrent migrateToLatest() runs apply each migration exactly once, and a lost migration lease is no longer silently re-acquired (#7).
  • Postgres:
    • fractional delays work
    • list cursors keep microsecond precision
    • acquisition locks only the job row
    • time comparisons use statement time
  • Worker config is validated when the worker is created.
  • Dashboard:
    • workers are notified only after a reschedule or delete commits
    • list filters are unified into a single filter bar

Packages

All packages released at 0.17.0: queuert, @queuert/postgres, @queuert/sqlite, @queuert/redis, @queuert/nats, @queuert/otel, @queuert/dashboard.