Oban. Lifeline
(Oban v2.24.1)
View Source
Naively transition jobs stuck executing back to available.
The Lifeline plugin periodically rescues orphaned jobs, i.e. jobs that are stuck in the
executing state because the node was shut down before the job could finish. Rescuing is
purely based on time, rather than any heuristic about the job's expected execution time or
whether the node is still alive.
If an executing job has exhausted all attempts, the Lifeline plugin will mark it discarded
rather than available.
🌟 Oban Pro's Lifeline
This plugin may transition jobs that are genuinely executing and cause duplicate execution.
For more accurate rescuing or to rescue jobs that have exhausted retry attempts, see
Oban.Pro.Lifeline.
Using the Plugin
Rescue orphaned jobs that are still executing after the default of 1 hour:
config :my_app, Oban,
lifeline: Oban.Lifeline,
...Override the default period to rescue orphans after a more aggressive period of 5 minutes:
config :my_app, Oban,
lifeline: [rescue_after: {5, :minutes}],
...Options
:interval— the time between rescue attempts, as either an integer number of milliseconds or anOban.Periodtuple like{1, :minute}. The default is60_000ms.:rescue_after— the maximum amount of time a job may execute before being rescued, as either an integer number of milliseconds or anOban.Periodtuple like{1, :hour}. 1 hour by default, and rescuing is performed once a minute.
Instrumenting with Telemetry
The Oban.Lifeline plugin adds the following metadata to the [:oban, :plugin, :stop]
event:
:rescued_jobs— a list of jobs transitioned back toavailable:discarded_jobs— a list of jobs transitioned todiscarded
When a run can't reach the database both lists are empty and an :error is added to the
metadata, as described in Oban.Telemetry.
Note: jobs only include id, queue, state fields.
Summary
Types
@type option() :: Oban.Plugin.option() | {:interval, Oban.Period.t()} | {:rescue_after, Oban.Period.t()}