chore(deps): update dependency oban to v2.19.4 #493
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
2.17.4
->2.19.4
Release Notes
oban-bg/oban (oban)
v2.19.4
Compare Source
Bug Fixes
[Validation] Partially revert removal of unused validators.
Some validations are actively used by the current version of Oban Pro and shouldn't have been
removed.
[Plugins] Handle and log all unexpected messages.
Some genservers handled unexpected messages while others did not. Now all plugins and other
genservers consistently handle those messages. Public facing modules, such as plugins, all log a
warning about the message while internal modules ignore them.
v2.19.3
Compare Source
Bug Fixes
[Install] Use
configure_new
for idempotent installation.Prevent overwriting existing
:oban
configuration when running installer.[Sonar] Correct stale node logic for sonar tracking.
The original code had a logical error. By calculating
stale
as current time + interval *multiplier, it would reject nodes that were recorded in the future relative to the current time
(which is unlikely to be the intended behavior) The new code correctly identifies stale nodes by
checking if they're older than the threshold.
Enhancements
[Worker] Check for worker functions rather than behaviour
Behaviours can't contain overlapping callbacks. In order to have a worker-like module that
defines it's own
timeout/1
orbackoff/1
, we must use an alternate callback.[Worker] Improve warning message on incorrect return from
perform/1
.[Telemetry] Skip logging peer events unless node leadership changes.
The default logger only outputs peer events when something changed: either the peer became
leader or lost the leader.
[Validation] Add schema validator for tuple options.
Being able to validate tuples eliminates the need for custom validator functions in several
locations.
[Oban] Compatiblity updates for changes in the upcoming Elixir v1.19
v2.19.2
Compare Source
Enhancements
[Oban] Allow setting a MFA in
:get_dynamic_repo
Anonymous functions don't work with OTP releases, as anonymous functions cannot be used in
configuration. Now a MFA tuple can be passed instead of a fun, and the scaling guide recommends
a function instead.
[Cron] Include configured timezone in cron job metadata
Along with the cron expression, stored as
cron_expr
, the configured timezone is also recordedas
cron_tz
in cron job metadata.[Cron] Add
next_at/2
andlast_at/2
for cron time calculationsThis implements jumping functions for cron expressions. Rather than naively iterating through
minutes, it uses the expression values to efficiently jump to the next or last cron run time.
[Executor] Always convert
queue_time
to native time unitThe telemetry docs state that measurements are recorded in
native
time units. However, thathasn't been the case for
queue_time
for a while now. It usually worked anyway native andnanosecond is of the same resolution, but now it is guaranteed.
Bug Fixes
[Peer] Correct leadership elections for the
Dolphin
engineMySQL always returns the number of entries attempted, even when nothing was added. The previous
match caused all nodes to believe they were the leader. This uses a secondary query within the
same transaction to detect if the current instance is the leader.
[Reindexer] Drop invalid indexes concurrently when reindexing.
The
DROP INDEX
query would lock the whole table with anACCESS EXCLUSIVE
lock and couldcause queries to fail unexpectedly.
[Testing] Use
Ecto.Type.cast/2
for backward compatibilityThe
cast!/2
function wasn't added until Ecto 3.12. This reverts time casting to usecast/2
for compatibility with earlier Ecto versions.
[Worker] Validate that the
unique
option isn't an empty list.An empty list was accepted at compile time, but wouldn't be valid later at runtime. Now the two
validations match for greater parity.
v2.19.1
Compare Source
Bug Fixes
[Mix] Improve igniter installer idempotency and compatibility.
The installer now uses
on_exists: :skip
when generating a migration, so it composes safelywith other igniter installers. It also removes unnecessary
add_dep
calls that would overwritea previously specified Oban version with
~> 2.18
.v2.19.0
Compare Source
Enhancements
[Oban] Start all queues in parallel on initialization.
The midwife now starts queues using an async stream to parallelize startup and minimize boot
time for applications with many queues.
[Oban] Safely return
nil
fromcheck_queue/2
when checking queues that aren't running.Checking on a queue that wasn't currently running on the local node now returns
nil
ratherthan causing a crash. This makes it safer to check the whether a queue is running at all without
a
try/catch
clause.[Oban] Add
check_all_queues/1
to gather all queue status in a single function.This new helper gathers the "check" details from all running queues on the local node. While it
was previously possible to pull the queues list from config and call
check_queue/2
on eachentry, this more accurately pulls from the registry and checks each producer concurrently.
[Oban] Add
delete_job/2
anddelete_all_jobs/2
operations.This adds
Oban.delete_job/2
,Oban.delete_all_jobs/2
, Engine callbacks, and associatedoperations for all native engines. Deleting jobs is now easier and safer, due to automatic state
protections.
[Engine] Record when a queue starts shutting down
Queue producer metadata now includes a
shutdown_started_at
field to indicate that a queueisn't just paused, but is actually shutting down as well.
[Engine] Add
rescue_jobs/3
callback for all engines.The
Lifeline
plugin formerly used two queries to rescue jobs—one to mark jobs with remainingattempts as
available
and another thatdiscarded
the remaining stuck jobs. Those are nowcombined into a single callback, with the base definition in the
Basic
engine.MySQL won't accept a select in an update statement. The Dolphin implementation of
rescue_jobs/3
uses multiple queries to return the relevant telemetry data and make multipleupdates.
[Cron] Introduce
Oban.Cron
withschedule_interval/4
The new
Cron
module allows processes, namely plugins, to get cron-like scheduled functionalitywith a single function call. This will allow plugins to removes boilerplate around parsing,
scheduling, and evaluating for cron behavior.
[Registry] Add
select/1
to simplify querying for registered modules.[Testing] Add
build_job/3
helper for easier testing.Extract the mechanism for verifying and building jobs out of
perform_job/3
so that it's usablein isolation. This also introduces
perform_job/2
for executing built jobs.[Telemetry] Add information on leadership changes to
oban.peer.election
event.An additional
was_leader?
field is included in[:oban, :peer, :election | _]
event metadatato make hooking into leadership change events simpler.
[Telemetry] Add callback powered logging for plugin events.
Events are now logged for plugins that implement the a new optional callback, and exceptions are
logged for all plugins regardless of whether they implement the callback.
This adds logging for
Cron
,Lifeline
,Pruner
,Stager
, andReindexer
.[Telemetry] Add peer election logging to default logger.
The default logger now includes leadership events to make identifying the leader, and leadership
changes between nodes, easier.
[Telemetry] Add option to restrict logging to certain events.
Logging in a busy system may be noisy due to job events, but there are other events that are
particularly useful for diagnosing issues. This adds an
events
option toattach_default_logger/1
to allow selective event logging.[Telemetry] Expose
default_handler_id/0
for telemetry testing.Simplifies testing whether the default logger is attached or detached in application code.
Chores
Postgres
toDatabase
because it isalso used for MySQL databases.
Bug Fixes
[Oban] Allow overwriting all
insert/*
functions arities afteruse Oban
.[Node] Correctly handle
:node
option forscale_queue/2
Scoping
scale_queue/2
calls to a single node didn't work as advertised due to some extravalidation for producer meta compatibility.
[Migration] Fix version query for databases with non-unique
oid
Use
pg_catalog.obj_description(object_oid, catalog_name)
, introduced in PostgreSQL 7.2, tospecify the
pg_class
catalog so only theoban_jobs
description is returned.[Pruner] Use state specific fields when querying for prunable jobs.
Using
scheduled_at
is not correct in all situations. Depending on job state, one ofcancelled_at
,discarded_at
, orscheduled_at
should be used.[Peer] Conditionally return the current node as leader for isolated peers.
Prevents returning the current node name when leadership is disabled.
[Testing] Retain time as microseconds for
scheduled_at
tests.Include microseconds in the
begin
anduntil
times used for scheduled_at tests with a delta.The prior version would truncate, which rounded the
until
down and broke microsecond levelchecks.
[Telemetry] Correct spelling of "elapsed" in
oban.queue.shutdown
metadata.v2.18.3
Compare Source
Enhancements
[Basic] Use the shared concat operator when appending errors.
The standard
push
operation for updates is designed for arrays and usesarray_append
internally. This replaces all use ofpush
with a fragment that uses the||
operator instead, which works for both arrays and jsonb.CockroachDB doesn't support arrays of jsonb, but they do support simple jsonb columns. Now we can append to the errors column in either format for CRDB compatibility.
Bug Fixes
[Queue] Link the dynamic queue supervisor and
Midwife
for automatic restarts.When a producer crashes it brings the queue's supervisor down with it. With enough database errors, the producer may crash repeatedly enough to exhaust restarts and bring down the DynamicSupervisor in charge of all queues.
Now the supervisor is linked to the midwife to ensure that the midwife restarts as well, and it restarts all of the queues.
[Testing] Handle
insert_all/3
with streams for the:inline
testing engine.The inline engine's
insert_all_jobs
callback incorrectly expected changesets to always be a list rather and couldn't handle streams.v2.18.2
Compare Source
Bug Fixes
[Repo] Prevent debug noise by ensuring default opts for standard transactions.
Without default opts each transaction is logged. Many standard operations execute each second, which makes for noisy logs. Now transaction opts are passed as a third argument to ensure defaults are applied.
[Repo] Increase transaction retry delay and increase with each attempt.
Bump the base transaction retry from 100ms to 500ms, and increase linearly between each successive attempt to provide deeper backoff. This alleviates pressure on smaller connection pools and gives more time to recover from contentions failures.
v2.18.1
Compare Source
Enhancements
[Repo] Automatically retry all transactions with backoff.
Avoid both expected an unexpected database errors by automatically retrying transactions. Some operations, such as serialization and lock not available errors, are likely to occur during standard use depending on how a database is configured. Other errors happen infrequently due to pool contention or flickering connections, and those should also be retried for increased safety.
This change is applied to
Oban.Repo.transaction/3
itself, so it will apply to every location that uses transactions.[Migration] Declare
tags
as an array oftext
rather thanvarchar
.We don't provide a limit on the size of tags and they could conceivably be larger than 256 characters. Externally the types are interchangeable, but internally there are minor advantages to using the text type.
There isn't a new migration; this change is only for new tables.
Bug Fixes
query!/4
toquery!
rather thanquery
without a bang.v2.18.0
Compare Source
🔭 Queue Shutdown Telemetry
A new queue shutdown event,
[:oban, :queue, :shutdown]
, is emitted by each queue when it terminates. The event originates from thewatchman
process, which tracks the total ellapsed time from when termination starts to when all jobs complete or the allotted period is exhausted.Any jobs that take longer than the
:shutdown_grace_period
(by default 15 seconds) are brutally killed and left as orphans. The ids of jobs left in an executing state are listed in the event'sorphaned
meta.This also adds
queue:shutdown
logging to the default logger. Only queues that shutdown with orphaned jobs are logged, which makes it easier to detect orphaned jobs and which jobs were affected:🚚 Distributed PostgreSQL Support
It's now possible to run Oban in distributed PostgreSQL databases such as Yugabyte. This is made possible by a few simple changes to the
Basic
engine, and a newunlogged
migration option.Some PostgreSQL compatible databases don't support unlogged tables. Making
oban_peers
unlogged isn't a requirement for Oban to operate, so it can be disabled with a migration flag:🧠 Job Observability
Job
stop
andexception
telemetry now includes the reported memory and total reductions from the job's process. Values are pulled withProcess.info/2
after the job executes and safely fall back to0
in the event the process has crashed. Reductions are a rough proxy for CPU load, and the new measurements will make it easier to identify computationally expensive or memory hungry jobs.In addition, thanks to the addition of
Process.set_label
in recent Elixir versions, the worker name is set as the job's process label. That makes it possible to identify which job is running in apid
via observer or live dashboard.v2.18.0 — 2024-07-26
Enhancements
[Job] Support simple
unique: true
andunique: false
declarationsUniqueness can now be enabled with
unique: true
and disabled withunique: false
from job options or a worker definition. Theunique: true
option uses all the standard defaults, but sets the period to:infinity
for compatibility with Oban Pro's newsimple
unique mode.[Cron] Remove forced uniqueness when inserting scheduled jobs.
Using uniqueness by default prevents being able to use the Cron plugin with databases that don't support uniqueness because of advisory locks. Luckily, uniqueness hasn't been necessary for safe cron insertion since leadership was introduced and scheduling changed to top-of-the-minute many versions ago.
[Engine] Introduce
check_available/1
engine callbackThe
check_available/1
callback allows engines to customize the query used to find jobs in theavailable
state. That makes it possible for alternative engines, such Oban Pro's Smart engine, to check for available jobs in a fraction of the time with large queues.[Peer] Add
Oban.Peer.get_leader/2
for checking leadershipThe
get_leader/2
function makes it possible to check which node is currently the leader regardless of the Peer implementation, and without having to query the database.[Producer] Log a warning for unhandled producer messages.
Some messages are falling through to the catch-all
handle_info/2
clause. Previously, they were silently ignored and it degraded producer functionality because inactive jobs with dead pids were still tracked asrunning
in the producer.[Oban] Use structured messages for most logger warnings.
A standard structure for warning logs makes it easier to search for errors or unhandled messages from Oban or a particular module.
Bug Fixes
[Job] Include all fields in the unique section of
Job.t/0
.The unique spec lacked types for both
keys
andtimestamp
keys.[Basic] Remove
materialized
option fromfetch_jobs/3
.The
MATERIALIZED
clause for CTEs didn't make a meaningful difference in job fetching accuracy. In some situations it caused a performance regression (which is why it was removed from Pro's Smart engine a while ago).v2.17.12
Compare Source
v2.17.11
Compare Source
Bug Fixes
[Oban] Handle deprecation warnings from Elixir 1.17
[Notifier] Prevent noisy logging about switching between modes.
There's an apparent race condition in Sonar between pruning stale nodes on
:ping
and updating the status after a notification. This primarily happens in development for two reasons:Using
monotonic_time/1
instead ofsystem_time/1
guards against clock drift/time warp effects.[Stager] Prevent notification status timeouts from bubbling into the Stager.
A clogged Ecto pool could cause cascading errors on startup due to a sequence of calls between the
Notifier
,Sonar
, andStager
.Sonar
sends a notification inhandle_continue
on startup.Notifier
waits for a connection from the Ecto pool.Stager
checks for the connection status on startup, which would eventually time out because theSonar
hadn't finished initializing.Stager
crashes from the timeout error.This makes the following changes to prevent this sequence of events:
Stager
no longer gets the sonar status during startup.Notifier
catches timeout errors fromSonar
checks, warns about it, then returns an:unknown
status.[Engine] Defensively check the process dictionary during inline testing.
Not all processes are guaranteed to return a value for the process dictionary. Sometimes a value was missing during inline testing, which would crash the test.
[Basic] Set
conflict?
flag when encountering a unique advisory lock.The
conflict?
flag wasn't set when inserting a unique job was blocked by an advisory lock. Now the flag is set on either a fetched duplicate, or when the advisory lock is set.[Job] Correct
replace_by_state_option
type by switching from keyword to tuples.[Config] Correctly type
shutdown_grace_period
as aninteger
rather than atimeout
.v2.17.10
Compare Source
Enhancements
[Oban] Make all generated functions from
use Oban
overridable.Now the functions generated by
use Oban
are all marked withdefoverridable
for extensibility.Bug Fixes
[Testing] Use
$callers
rather than$ancestors
for ancestry tree check.We care about Tasks for inline testing checks, not normal supervision tree ancestry. The
$callers
entry is the appropriate mechanism to find the trail of calling processes:v2.17.9
Compare Source
Enhancements
[Testing] Check process ancestry tree for
with_testing_mode
override.Cascade the
with_testing_mode
block to nested processes that make use of:$ancestry
in the process dictionary, i.e. tasks. Now enqueuing a job within spawned processes likeTask.async
orTask.async_stream
will honor the testing mode specified inwith_testing_mode/2
.[PG] Support alternative namespacing in
PG
notifierBy default, all Oban instances using the same
prefix
option would receive notifications from each other. Now you can use thenamespace
option to separate instances that are in the same cluster without changing theprefix
.Bug Fixes
[Oban] Restore zero arity version of
pause_all_queues/0
Both pause and resume variants lost their default argument in a refactor that shifted around guard clauses.
[Oban] Add
:oban_draining
to process dict while drainingThe flag marks the test process while draining to give hints to the executor and engines. It fixes an incompatibility between
Oban.drain_queue/2
and Pro'sTesting.drain_jobs/2
.v2.17.8
Compare Source
Enhancements
[Backoff] Backoff retry on DBConnection and Postgrex errors from GenServer calls.
GenServer calls that result in a
ConnectionError
orPostgrex.Error
should also be caught and retried rather than crashing on the first attempt.Bug Fixes
[Notifier] Check for a live notifier process and propagate notify errors.
The
Notifier.notify/1
spec showed it would always return:ok
, but that wasn't the case when the notifier was disconnected or the process was no longer running. Now an error tuple is returned when a notifier process isn't running.This situation happened most frequently during shutdown, particularly from external usage of the Notifier like an application or the
oban_met
package.In addition, the errors bubble up through top level
Oban
functions likescale_queue/1
,pause_queue/1
, etc. to indicate that the operation can't actually succeed.[Peers.Postgres] Rescue
DBConnection.ConnectionError
in peer leadership check.Previously, only
Postgrex.Error
exceptions were rescued and other standard connection errors were ignored, crashing the Peer. Because leadership is checked immediately after the peer initializes, any connection issues would trigger a crash loop that could bring down the rest of the supervision tree.v2.17.7
Compare Source
Bug Fixes
[Notifier] Prevent Sonar from running in
:testing
modes.Sonar has no purpose during tests, and it can cause sandbox issues when tests run with the Postgres notifier.
[Oban] Correctly handle pause and resume all with opts.
The primary clause had two default arguments and it was impossible to call
pause_all_queues/1
orresume_all_queues/1
with opts and no name.v2.17.6
Compare Source
Enhancements
[Cron] Include cron indicator and original cron expression in meta.
When the Cron plugin inserts jobs the original, unnormalized cron expression is now stored in a job's meta under the
cron_expr
key. For compatibility with Pro'sDynamicCron
, meta also hascron: true
injected.[Worker] Change
backoff/1
spec to allow immediate rescheduling by returning0
The callback now specifies a
non_neg_integer
to allow retrying 0 seconds into the future. This matches the abilitiy to use{:snooze, 0}
.Bug Fixes
[Notifier] Revert using single connection to deliver notices.
Production use of the single notifier connection in various environments showed timeouts from bottlenecks in the single connection could crash the connection and start new ones, leaving extra idle processes. In addition, Use interpolated NOTIFY instead of pg_notify with a JSON argument added parsing load because it could no longer use prepared statements.
[Worker] Apply custom backoff on timeout and unhandled exit
A worker's custom
backoff/1
wasn't applied after aTimeoutError
or unhandled exit. That's because the producer stores the executor struct before resolving the worker module. Now the module is resolved again to ensure custombackoff/1
are used.[Job] Revert setting the default priority key in Job schema.
The Ecto default was removed to allow overriding the default in the database and it was purposefully removed.
v2.17.5
Compare Source
Enhancements
[Notifier] Use the Postgres notifier's connection to deliver notifications.
The Postgres notifier holds a single connection for listening and relaying messages. However, it wasn't used to dispatch messages; that was left to queries through the Ecto pool. Those queries were noisy and put unnecessary load on the pool, particularly from insert notifications.
Now notifications are delivered through the notifier's connection—they don't require a pool checkout, and they won't clutter Ecto logs or telemetry.
[Engine] Emit insert trigger notification directly from
Engine
callbacks.Notifications are now sent from the engine, within the
insert_*
telemetry block, so the timing impact is visible. In addition, notifications aren't emitted forscheduled
jobs, as there's nothing ready for producers to fetch.Bug Fixes
[Notifier] Track and compare sonar pings using the correct time unit.
The notifier's status tracker pruned stale nodes using mismatched time units, causing constant status change events despite nothing changing. This ensures the recorded and compared times are both milliseconds, not a mixture of seconds and native time.
[Cron] Retain
@reboot
cron entries until node becomes leader.With rolling deploys it is frequent that a node isn't the leader the first time cron evaluates. However,
@reboot
expressions were discarded after the first run, which prevented reboots from being inserted when the node acquired leadership.[Oban] Require Ecto v3.10 to support
materialized
flag added in the previous patch.The
materialized
option wasn't supported by Ecto until v3.10. Compiling with an earlier version causes a compilation error.Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.