View Source Oban.Plugins.Lifeline (Oban v2.11.0)

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.

🌟 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 the DynamicLifeline plugin in Oban Pro.

Using the Plugin

Rescue orphaned jobs that are still executing after the default of 60 minutes:

config :my_app, Oban,
  plugins: [Oban.Plugins.Lifeline],
  ...

Override the default period to rescue orphans after a more aggressive period of 5 minutes:

config :my_app, Oban,
  plugins: [{Oban.Plugins.Lifeline, rescue_after: :timer.minutes(5)}],
  ...

Options

  • :rescue_after — the maximum amount of time, in milliseconds, that a job may execute before being rescued. 60 minutes by default, and rescuing is performed once a minute.

Instrumenting with Telemetry

The Oban.Plugins.Lifeline plugin adds the following metadata to the [:oban, :plugin, :stop] event:

  • :rescued_count — the number of jobs transitioned back to available

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Types

Specs

option() ::
  {:conf, Oban.Config.t()}
  | {:interval, timeout()}
  | {:name, GenServer.name()}
  | {:rescue_after, pos_integer()}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.