ObanDoctor.Check.Worker.NoMaxAttempts (oban_doctor v0.2.2)

Copy Markdown View Source

Checks for workers that don't specify max_attempts.

Oban's default max_attempts is 20, which is often too high for most workers. Jobs that fail 20 times can clog up your queue and waste resources on operations that are unlikely to succeed.

Most workers should specify an explicit max_attempts based on:

  • Whether the operation is idempotent
  • Expected failure modes (network issues vs bugs)
  • Time sensitivity of the job

How to fix

Add max_attempts to your worker definition:

use Oban.Worker, queue: :default, max_attempts: 3

See Oban.Worker options.

Configuration

In .oban_doctor.exs:

checks: [
  no_max_attempts: [
    # Disable the check entirely
    enabled: false,

    # Or exclude specific workers from this check
    excluded_workers: [MyApp.Workers.LegacyWorker]
  ]
]