All Versions
48
Latest Version
Avg Release Cycle
20 days
Latest Release
26 days ago

Changelog History
Page 1

  • v2.9.2 Changes

    September 27, 2021
    • [Oban] Loosen telemetry requirement to allow either 0.4 or 1.0 without forcing apps to use an override.
  • v2.9.1 Changes

    September 23, 2021

    ๐Ÿ›  Fixed

    • ๐Ÿ‘ท [Oban] Correctly handle prefix in cancel_job and cancel_all_jobs.

    • [Oban] Safely guard against empty changeset lits passed to insert_all/2,4.

  • v2.9.0 Changes

    September 15, 2021

    ๐Ÿ‘ท Optionally Use Meta for Unique Jobs

    ๐Ÿ‘ท It's now possible to use the meta field for unique jobs. Unique jobs have ๐Ÿ‘ท always supported worker, queue, and args fields. That was flexible, but ๐Ÿ‘ฎ forced applications to put ad-hoc unique values in args when they should really be in meta.

    ๐Ÿ‘ The meta field supports keys, just like args. That makes it possible to ๐Ÿ’… use highly efficient fingerprint style uniqueness (and possibly drop the index on args, if desired).

    ๐Ÿ–จ Here's an example of using a single "fingerprint" key in meta for uniqueness:

    defmodule MyApp.FingerprintWorker do
      use Oban.Worker, unique: [fields: [:worker, :meta], keys: [:fingerprint]]
    
      @impl Worker
      def new(args, opts) do
        fingerprint = :erlang.phash2(args)
    
        super(args, Keyword.put(opts, :meta, %{fingerprint: fingerprint}))
      end
    end
    

    0๏ธโƒฃ For backward compatiblity meta isn't included in unique fields by default.

    Expanded Start and Scale Options

    โ™ป๏ธ After extensive refactoring to queue option management and validation, now it's ๐Ÿ‘ possible to start and scale queues with all supported options. Previously ๐Ÿ‘ start/stop functions only supported the limit option for dynamic scaling, reducing runtime flexibility considerably.

    Now it's possible to start a queue in the paused state:

    Oban.start_queue(queue: :dynamic, paused: true)
    

    ๐Ÿ‘ Even better, for apps that use an alternative engine like the SmartEngine from Oban Pro, it's possible to start a dynamic queue with options like global concurrency or rate limiting:

    Oban.start_queue(queue: :dynamic, local_limit: 10, global_limit: 50)
    

    All options are also passed through scale_queue, locally or globally, even ๐Ÿ‘ allowing you to reconfigure a feature like rate limiting at runtime:

    Oban.scale_queue(queue: :dynamic, rate_limit: [allowed: 50, period: 60])
    

    โž• Added

    • [Oban] Add Oban.cancel_all_jobs/1,2 to cancel multiple jobs at once, within an atomic transaction. The function accepts a Job query for complete control over which jobs are cancelled.

    • [Oban] Add Oban.retry_all_jobs/1,2 to retry multiple jobs at once, within an atomic transaction. Like cancel_all_jobs, it accepts a query for fine-grained control.

    • [Oban] Add with_limit option to drain_queue/2, which controls the number of jobs that are fetched and executed concurrently. When paired with with_recursion this can drastically speed up interdependent job draining, i.e. workflows.

    • [Oban.Telemetry] Add telemetry span events for all engine and notifier actions. Now all database operations are covered by spans.

    • [Oban.Migrations] Add create_schema option to prevent automatic schema creation in migrations.

    ๐Ÿ”„ Changed

    • [Oban] Consistently include a :snoozed count in drain_queue/2 output. Previously the count was only included when there was at least one snoozed job.

    • โœ… [Oban.Testing] Default to attempt: 1 for perform_job/3, as a worker's perform/1 would never be called with attempt: 0.

    ๐Ÿ›  Fixed

    • [Oban.Queue.Supervisor] Change supervisor strategy to :one_for_all.

    Queue supervisors used a :rest_for_one strategy, which allowed the task supervisor to keep running when a producer crashed. That allowed duplicate long-lived jobs to run simultaneously, which is a bug in itself, but could also cause attempt > max_attempts violations.

    • ๐Ÿ”Œ [Oban.Plugins.Cron] Start step ranges from the minimum value, rather than for the entire set. Now the range 8-23/4 correctly includes [8, 12, 16, 20].

    • [Oban.Plugins.Cron] Correcly parse step ranges with a single value, e.g. 0 1/2 * * *

    • ๐Ÿ“‡ [Oban.Telemetry] Comply with :telemetry.span/3 by exposing errors as reason in metadata

  • v2.8.0 Changes

    July 30, 2021

    โฑ Time Unit Scheduling

    โฑ It's now possible to specify a unit for :schedule_in, rather than always โฑ assuming seconds. This makes it possible to schedule a job using clearer โฑ minutes, hours, days, or weeks, e.g. schedule_in: {1, :minute} or โฑ schedule_in: {3, :days}.

    ๐Ÿ”„ Changed

    • โœ… [Oban.Testing] Accept non-map args to perform_job/3 for compatibility with overridden Worker.new/2 callbacks.

    • โฑ [Oban.Queue.Producer] Include some jitter when scheduling queue refreshes to prevent queues from refreshing simultaneously. In extreme cases, refresh contention could cause producers to crash.

    ๐Ÿ›  Fixed

    • โช [Oban.Queue.Executor] Restore logged warnings for unexpected job results by retaining the safe flag during normal execution.

    • ๐Ÿ”Œ [Oban.Plugins.Gossip] Catch and discard unexpected messages rather than crashing the plugin.

    • โœ… [Oban.Testing] Eliminate dialyzer warnings by including repo option in the Oban.Testing.perform_job/3 spec.

  • v2.7.2 Changes

    June 10, 2021

    ๐Ÿ›  Fixed

    • [Oban.Plugins.Pruner] Consider cancelled_at or discarded_at timestamps when querying prunable jobs. The previous query required an attempted_at value, even for cancelled or discarded jobs. If a job was cancelled before it was attempted then it wouldn't ever be pruned.

    • ๐Ÿ”Œ [Oban.Plugins.Gossip] Correct exit handling during safe checks. Occasionally, producer checks time out and the previous catch block didn't handle exits properly.

  • v2.7.1 Changes

    May 26, 2021

    ๐Ÿ›  Fixed

    • โช [Oban.Telemetry] Restore the :job key to [:oban, :job, :start] events. It was mistakenly removed during a refactoring.
  • v2.7.0 Changes

    May 25, 2021

    ๐Ÿ”Œ Pluggable Notifier

    The PubSub functionality Oban relies on for starting, stopping, scaling, and pausing queues is now pluggable. The previous notifier was hard-coded to use Postgres for PubSub via LISTEN/NOTIFY. Unfortunately, LISTEN/NOTIFY doesn't work for PG Bouncer in "Transaction Mode." While relatively few users run in "Transaction Mode," it is increasingly common and deserved a work-around.

    0๏ธโƒฃ Oban.Notifier defines a minimal behaviour and Oban ships with a default implementation, Oban.PostgresNotifier, based on the old LISTEN/NOTIFY ๐Ÿ”ง module. You can specify a different notifier in your Oban configuration:

    config :my_app, Oban,
      notifier: MyApp.CustomNotifier,
      repo: MyApp.Repo,
      ...
    

    An alternate [pg/pg2 based notifier][pgn] is available in Oban Pro.

    Replacing Opts on Unique Conflict

    โšก๏ธ The replace_args option for updating args on unique conflict is replaced with โšก๏ธ a highly flexible replace option. Using replace, you can update any job field when there is a conflict. Replace works for any of the following fields: โฑ args, max_attempts, meta, priority, queue, scheduled_at, tags, ๐Ÿ‘ท worker.

    For example, to change the priority to 0 and increase max_attempts to 5 when there is a conflict:

    BusinessWorker.new(
      args,
      max_attempts: 5,
      priority: 0,
      replace: [:max_attempts, :priority]
    )
    

    โฑ Another example is bumping the scheduled time to 1 second in the future on โฑ conflict. Either scheduled_at or schedule_in values will work, but the โฑ replace option is always scheduled_at.

    UrgentWorker.new(args, schedule_in: 1, replace: [:scheduled_at])
    

    โž• Added

    • ๐Ÿ‘ท [Oban.Job] A new conflict? field indicates whether a unique job conflicted with an existing job on insert.

    • [Oban.Telemetry] Always populate the unsaved_error field for error or discard events. Previously, the field was empty for discard events.

    • ๐Ÿ‘ท [Oban.Queue.Engine] Define a cancel_job/2 callback in the engine and move cancellation from the query module to the BasicEngine.

    ๐Ÿ”„ Changed

    • โ™ป๏ธ [Oban.Testing] Thanks to a slight refactoring, the perform_job/3 helper now emits the same telemetry events that you'd have in production. The refactoring also exposed and fixed an inconsistency around invalid snooze handlers.

    • โœ… [Oban.Testing] Expose Testing.all_enqueued/0, an alternate clause that doesn't require any options. This new clause makes it possible to check for any enqueued jobs without filters.

    • ๐Ÿ”Œ [Oban.Plugins.Stager] Limit the number of jobs staged at one time to prevent timeout errors while staging a massive number of jobs.

    ๐Ÿ›  Fixed

    • [Oban.Repo] Respect ongoing transactions when using get_dynamic_repo. Prior to this fix, calls that use Oban.Repo, such as Oban.insert/2, could use a different repo than the one used in the current transaction.
  • v2.6.1 Changes

    April 02, 2021

    ๐Ÿ›  Fixes

    • [Oban.Drainer] Always use the BasicEngine for draining, regardless of the currently configured engine.
  • v2.6.0 Changes

    April 02, 2021

    โฌ†๏ธ ๐ŸŒŸ Web and Pro users should check the [v2.6 upgrade guide][v26ug] for a complete walkthrough.

    ๐Ÿ”Œ Pluggable Queue Engines

    Queue producers now use an "engine" callback module to manage demand and work โœจ with the database. The engine provides a clean way to expand and enhance the functionality of queue producers without modifying the solid foundation of queue supervision trees. Engines make enhanced functionality such as global concurrency, local rate limiting and global rate limiting possible!

    The BasicEngine is the default, and it retains the exact functionality of previous Oban versions. To specify the engine explicitly, or swap in an ๐Ÿ”ง alternate engine, set it in your configuration:

    config :my_app, Oban,
      engine: Oban.Queue.BasicEngine,
      ...
    

    โฌ†๏ธ See the [v2.6 upgrade guide][v26ug] for instructions on swapping in an alternate engine.

    Recursive Queue Draining

    The ever-handy Oban.drain_queue/1,2 function gained a new with_recursion ๐Ÿ‘ท option, which makes it possible to test jobs that insert more jobs when they execute. When with_recursion is enabled the queue will keep executing until no โฑ jobs are available. It even composes with with_scheduled!

    โœ… In practice, this is especially useful for testing dependent workflows.

    ๐Ÿ”Œ Gossip Plugin for Queue Monitoring

    ๐Ÿ”Œ The new gossip plugin uses PubSub to efficiently exchange queue state information between all interested nodes. This allows Oban instances to broadcast state information regardless of which engine they are using, and without storing anything in the database.

    โฌ†๏ธ See the [v2.6 upgrade guide][v26ug] for details on switching to the gossip ๐Ÿ”Œ plugin.

    โž• Added

    • ๐Ÿ‘ท [Oban.Job] Inject the current conf into the jobs struct as virtual field, making the complete conf available within perform/1.

    • [Oban.Notifier] Add unlisten/2, used to stop a process from receiving notifications for one or more channels.

    ๐Ÿ”„ Changed

    • [Oban.Telemetry] Stop emitting circuit events for queue producers. As producers no longer poll, the circuit breaker masked real errors more than it guarded against sporatic issues.

    • [Oban.Telemetry] Delay [:oban, :supervisor, :init] event until the complete supervision tree finishes initialization.

    • [Oban.Migration] Stop creating an oban_beats table entirely.

    ๐Ÿ›  Fixed

    • โฑ [Oban.Plugins.Cron] Prevent schedule overflow right before midnight
  • v2.5.0 Changes

    February 26, 2021

    Top of the Minute Cron

    โฑ Rather than scheduling cron evaluation 60 seconds after the server starts, โฑ evaluation is now scheduled at the top of the next minute. This yields several ๐Ÿ‘Œ improvements:

    • ๐Ÿ‘ท More predictable timing for cron jobs now that they are inserted at the top of the minute. Note that jobs may execute later depending on how busy queues are.
    • ๐Ÿ‘ท Minimize contention between servers inserting jobs, thanks to the transaction lock acquired by each plugin.
    • ๐Ÿ‘ท Prevent duplicate inserts for jobs that omit the completed state (when server start time is staggered the transaction lock has no effect)

    ๐Ÿ”Œ Repeater Plugin for Transaction Pooled Databases

    Environments that can't make use of PG notifications, i.e. because they use ๐Ÿ‘ท PgBouncer with transaction pooling, won't process available jobs reliably. The ๐Ÿ†• new Repeater plugin provides a workaround that simulates polling functionality for producers.

    ๐Ÿ”Œ Simply include the Repeater in your plugin list:

    config :my_app, Oban,
      plugins: [
        Oban.Plugins.Pruner,
        Oban.Plugins.Stager,
        Oban.Plugins.Repeater
      ],
      ...
    

    ๐Ÿ“‡ Include Perform Result in Job Telemetry Metadata

    ๐Ÿ“‡ The metadata for [:oban, :job, :stop] telemetry events now include the job's ๐Ÿ‘ท perform/1 return value. That makes it possible to extract job output from other processes:

    def handle_event([:oban, :job, :stop], _timing, meta, _opts) do
      IO.inspect(meta.result, label: "return from #{meta.job.worker}")
    
      :ok
    end
    

    โž• Added

    • ๐Ÿ‘ [Oban] Support a changeset function in addition to a changeset in insert_all/4. Inserting jobs within a multi is even more powerful.

    • ๐Ÿ‘ท [Oban.Queue.Executor] Stash a timed job's pid to enable inner process messaging, notably via telemetry events.

    ๐Ÿ”„ Changed

    • โฌ†๏ธ [Oban] Upgrade minimum Elixir version from 1.8 to 1.9.

    • ๐Ÿ”Œ [Oban.Plugins.Cron] Individually validate crontab workers and options, providing more descriptive errors at the collection and entry level.

    • ๐Ÿ‘ท [Oban] Simplify the job cancelling flow for consistency. Due to race conditions it was always possible for a job to complete before it was cancelled, now that flow is much simpler.

    • [Oban.Queue.Producer] Replace dispatch cooldown with a simpler debounce mechanism.

    • ๐Ÿ”Œ [Oban.Plugins.Stager] Limit the number of notify events to one per queue, rather than one per available job.

    ๐Ÿ›  Fixed

    • [Oban.Queue.Producer] Handle unclean exits without an error and stack, which prevents "zombie" jobs. This would occur after multiple hot upgrades when the worker module changed, as the VM would forcibly terminate any processes running the old modules.

    • [Oban] Specify that the changeset_wrapper type allows keys other than :changesets, fixing a dialyzer type mismatch.

    โœ‚ Removed

    • ๐Ÿšš [Oban] Remove the undocumented version/0 function in favor of using the standard Application.spec/2