Changelog History
Page 3
-
v2.4.0 Changes
January 26, 2021๐ Centralized Stager Plugin
โฑ Queue producers no longer poll every second to stage scheduled jobs. Instead, ๐ the new
Oban.Plugins.Stager
plugin efficiently handles staging from a single location. This reduces overall load on the BEAM and PostgreSQL, allowing apps to easily run hundreds of queues simultaneously with little additional overhead.In a test with a single Ecto connection and 512 queues the CPU load went from 60.0% BEAM / 21.5% PostgreSQL in v2.3.4 to 0.5% BEAM / 0.0% PostgreSQL.
๐ The stager plugin is automatically injected into Oban instances and there isn't ๐ง any additional configuration necessary. However, if you've set a
poll_interval
๐ for Oban or an individual queue you can safely remove it.Overhauled Cron
The CRON parser is entirely rewritten to be simpler and dramatically smaller. ๐ The previous parser was built on
nimble_parsec
and while it was fast, the ๐ compiled parser added ~5,500LOC to the code base. Thanks to a suite of property โ tests we can be confident that the new parser behaves identically to the ๐ previous one, and has much clearer error messages when parsing fails.๐ Along with a new parser the
crontab
functionality is extracted into the ๐Oban.Plugins.Cron
plugin. For backward compatibility, top-levelcrontab
and ๐timezone
options are transformed into a plugin declaration. If you'd like to ๐ง start configuring the plugin directly change your config from:config :my_app, Oban, crontab: [{"* * * * *", MyApp.Worker}], timezone: "America/Chicago" ...
To this:
config :my_app, Oban, plugins: [ {Oban.Plugins.Cron, crontab: [{"* * * * *", MyApp.Worker}], timezone: "America/Chicago"} ]
๐ The plugin brings a cleaner implementation, simplified supervision tree, and ๐ง eliminates the need to set
crontab: false
in test configuration.๐ Improved Indexes for Unique Jobs
๐ท Applications may have thousands to millions of completed jobs in storage. As the ๐ table grows the performance of inserting unique jobs can slow drastically. A new V10 migration adds necessary indexes, and paired with improved query logic it alleviates insert slowdown entirely.
๐ท For comparison, a local benchmark showed that in v2.3.4 inserting a unique job ๐ท into a table of 1 million jobs runs around 4.81 IPS. In v2.4.0 it runs at 925.34 IPS, nearly 200x faster.
The V10 migration is optional. If you decide to migrate, first create a new migration:
mix ecto.gen.migration upgrade_oban_jobs_to_v10
Next, call
Oban.Migrations
in the generated migration:defmodule MyApp.Repo.Migrations.UpdateObanJobsToV10 do use Ecto.Migration def up do Oban.Migrations.up(version: 10) end def down do Oban.Migrations.down(version: 10) end end
โ Added
[Oban] Add
[:oban, :supervisor, :init]
event emitted when an Oban supervisor starts.๐ [Oban.Telemetry] Wrap built-in plugins with telemetry spans and consistently include
conf
in all telemetry events.[Oban.Config] Improve the error messages raised during initial validation. Also, the
Config
module is now public with light documentation.โ [Oban.Testing] Support specifying a default prefix for all test assertions. This comes with improved assertion messages that now include the prefix.
[Oban.Repo] Add
delete/3
as a convenient wrapper aroundc:Ecto.Repo.delete/2
.๐ท [Oban.Job] New check constraints prevent inserting jobs with an invalid
priority
, negativemax_attempts
or anattempt
number beyond the maximum.
๐ Changed
- ๐ [Oban.Telemetry] Deprecate and replace
span/3
usage in favor of the official:telemetry.span/3
, which wasn't available whenspan/3
was implemented.
๐ Fixed
- [Oban] Inspect the error reason for a failed
insert!/2
call before it is raised as an error. Wheninsert!/2
was called in a transaction the error could be:rollback
, which wasn't a valid error.
-
v2.3.4 Changes
December 02, 2020๐ Fixed
- โก๏ธ [Oban.Worker] Update
from_string/1
to correctly work with modules that weren't loaded.
- โก๏ธ [Oban.Worker] Update
-
v2.3.3 Changes
November 10, 2020๐ Changed
- ๐ท [Oban.Migration] Conditionally skip altering
oban_job_state
if thecancelled
state is already present. This allows for a smoother upgrade path for users running PG < 12. See the notes for v2.3.0 for more details.
- ๐ท [Oban.Migration] Conditionally skip altering
-
v2.3.2 Changes
November 06, 2020๐ Fixed
โช [Oban.Migration] Restore indexes possibly removed by changing
oban_job_state
. This only applies to PG older than version 12.๐ [Oban.Plugins.Pruner] Prune
cancelled
jobs along withcompleted
ordiscarded
.
-
v2.3.1 Changes
November 06, 2020๐ Changed
- ๐ท [Oban.Migration] Conditionally alter
oban_job_state
if the PG version is 12 or greater. This is vastly faster than the renaming, adding and dropping required for older PG versions.
- ๐ท [Oban.Migration] Conditionally alter
-
v2.3.0 Changes
November 06, 2020Migration Required (V9)
๐ท Migration V9 brings the new
cancelled
state, acancelled_at
column, and jobmeta
.Older versions of PostgreSQL, prior to version 12, don't allow altering an enum within a transaction. If you're running an older version and want to prevent a table rewrite you can add the new cancelled at state before running the V9 migration.
Create a migration with
@disable_ddl_transaction true
declared and run the ๐ท commandALTER TYPE oban_job_state ADD VALUE IF NOT EXISTS 'cancelled'
. The V9 ๐ migration will see that the cancelled value exists and won't attempt to modify the enum.After you've sorted adding the
cancelled
state (or ignored the issue, because ๐ท you're either running PG >= 12 or don't have many jobs retained), generate a new migration:mix ecto.gen.migration upgrade_oban_jobs_to_v9
Next, call
Oban.Migrations
in the generated migration:defmodule MyApp.Repo.Migrations.UpdateObanJobsToV9 do use Ecto.Migration def up do Oban.Migrations.up(version: 9) end def down do Oban.Migrations.down(version: 9) end end
โฌ๏ธ Oban will manage upgrading to V9 regardless of the version your application is currently using, and it will roll back a single version.
โ Added
๐ท [Oban.Job] Add new
meta
field for storing arbitrary job data that isn't appropriate asargs
.๐ท [Oban.Job] Introduce a
cancelled
state, along with a newcancelled_at
timestamp field. Cancelling a job viaOban.cancel_job
(or via Oban Web) now marks the job ascancelled
rather thandiscarded
.๐ท [Oban.Worker] Add
from_string/1
for improved worker module resolution.๐ [Oban.Telemetry] Pass the full
job
schema in telemetry metadata, not only select fields. Individual fields such asargs
,worker
, etc. are still passed for backward compatibility. However, their use is deprecated and they are no longer documented.
๐ Fixed
[Oban.Notifier] Fix resolution of
Oban.Notifier
child process inOban.Notifier.listen/2
.๐ท [Oban.Queue.Producer] Fix cancelling jobs without a supervised process. In some circumstances, namely a hot code upgrade, the job's process could terminate without the producer tracking it and leave the job un-killable.
[Oban] Only convert invalid changesets into
ChangesetError
frominsert!
. This prevents unexpected errors wheninsert!
is called within a transaction after the transaction has rolled back.
-
v2.2.0 Changes
October 12, 2020โ Added
[Oban] Replace local dynamically composed names with a registry. This dramatically simplifies locating nested children, avoids unnecessary atom creation at runtime and improves the performance of config lookups.
[Oban.Repo] The new
Oban.Repo
module wraps interactions with underlying Ecto repos. This ensures consistent prefix and log level handling, while also adding full dynamic repo support.
The
Oban.Repo
wrapper should be used when authoring plugins.๐ท [Oban.Job] Augment the unique keys option with
replace_args
, which allows enqueuing a unique job and replacing the args subsequently. For example, given a job with these args:%{some_value: 1, id: 123}
Attempting to insert a new job:
```elixir %{some_value: 2, id: 123} |> MyJob.new(schedule_in: 10, replace_args: true unique: [keys: [:id]]) |> Oban.insert() ```
Will result in a single job with the args:
```elixir %{some_value: 2, id: 123} ```
[Oban] Add
Oban.check_queue/1,2
for runtime introspection of a queue's state. It displays a compactly formatted breakdown of the queue's configuration, a list of running jobs, and static identity information.๐ท [Oban] Add
Oban.retry_job/1,2
, used to manually retry adiscarded
orretryable
job.๐ [Oban.Telemetry] Include
tags
as part of the metadata for job events.
๐ Changed
- 0๏ธโฃ [Oban.Worker] The default backoff algorithm now includes a small amount of jitter. The jitter helps prevent jobs that fail simultaneously from repeatedly retrying together.
๐ Fixed
0๏ธโฃ [Oban.Job] Don't include
discarded
state by default when accounting for uniqueness.๐ [Oban.Cron] Fully support weekeday ranges in crontab expressions. Previously, given a weekday range like
MON-WED
the parser would only retain theMON
.
-
v2.1.0 Changes
August 21, 2020๐ Fixed
โ [Oban.Testing] Modify the behaviour checking in
perform_job/3
so that it considers all behaviours.๐ [Oban.Plugins.Pruner] Use distinct names when running multiple Oban instances in the same application.
โ Added
[Oban] In addition to the standard queue-name / limit keyword syntax it is now possible to define per-queue options such as
:poll_interval
,:dispatch_cooldown
,:paused
, and even override the:producer
module.๐ท [Oban] Cancelling a running job now records an error on the job if it was running at the time it was cancelled.
๐ท [Oban.Job] Allow using
:discarded
as a unique state and expose all possible states throughOban.Job.states/0
.๐ท [Oban.Worker] Allow returning
{:discard, reason}
fromperform/1
, where the reason is recorded in the job's errors array. If no reason is provided then a default of "None" is used. All discarded jobs will have an error now, whether discarded manually or automatically.๐ท [Oban.Job] Add support for uniqueness across sub-args with the
:keys
attribute. This makes it possible to only use a few values from a job to determine uniqueness. For example, a job that includes a lot of metadata but must be considered unique based on a:url
field can specifykeys: [:url]
.
๐ Changed
๐ท [Oban.Worker] Wrap
{:error, reason}
and{:discard, reason}
in a properOban.PerformError
exception with a customized message. This ensures that the:error
value passed to telemetry handlers is an exception and not a raw term.๐ท [Oban.Worker] Wrap job timeouts in
Oban.TimeoutError
with a customized message indicating the worker and timeout value. This replaces the raw:timeout
atom that was reported before.๐ท [Oban.Worker] Wrap caught exits and throws in
Oban.CrashError
with a formatted message. This means the:error
value passed to telemetry is always a proper exception and easier to report.๐ท [Oban.Worker] Stop reporting internal stacktraces for timeouts, discards or error tuples. The stacktrace was useless and potentially misleading as it appeared that the error originated from Oban rather than the worker module.
-
v2.0.0 Changes
July 10, 2020No changes from [2.0.0-rc.3][].
-
v2.0.0-rc.3 Changes
July 01, 2020๐ Fixed
๐ป [Oban.Crontab.Cron] Do not raise an
ArgumentError
exception when the crontab configuration includes a step of 1, which is a valid step value.[Oban.Telemetry] Correctly record
duration
andqueue_time
using native time units, but log them using microseconds. Previously they used a mixture of native and microseconds, which yielded inconsistent values.
โ Added
- 0๏ธโฃ [Oban.Telemetry] Include job
queue_time
in the default logger output.
๐ Changed
- ๐ [Oban.Plugins.Pruner] The
FixedPruner
is renamed toPruner
and allows users to configure themax_age
value. This partially reverses the breaking change imposed by the move fromprune
to theFixedPruner
plugin, though there isn't any support formax_len
or dynamic pruning.