oban v2.5.0 Release Notes

Release Date: 2021-02-26 // about 3 years ago
  • 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