QueueKeeperCheck.Config (queue_keeper_check v0.3.0)

Copy Markdown View Source

Thresholds and safety limits. All check durations are in seconds. Pass overrides as keyword lists:

QueueKeeperCheck.run(MyApp.Repo, backlog: [max_depth: 5_000], hanging: [default_budget: 120])

Check defaults:

checkoptiondefaultmeaning
:orphanedafter3600executing longer than this, far beyond any expected runtime (matches Oban Lifeline's default rescue_after of 60 min). Measures execution age only: the job may be orphaned by a node crash, or may still be running
:hangingdefault_budget300executing longer than the worker's budget
:hangingbudgets%{}per-worker budgets, e.g. %{"MyApp.VideoWorker" => 1800}
:backlogmax_depth1000due jobs (available, or scheduled/retryable whose time has passed) per queue
:backlogmax_latency300age of the oldest due job per queue
:stalledwindow60due jobs older than backlog.max_latency and no job attempted in this queue within the window
:stalledlookback3600completed jobs count as recent activity only if they were scheduled at most this many seconds before the queue's oldest due job (bounds the query; see QueueKeeperCheck.Checks.stalled/4)
:retry_stormwindow300look-back window
:retry_stormmin_retries20retrying/retried jobs per worker (see below)
:retry_storminclude_completedfalsealso count completed jobs on attempt >= 2 attempted in the window. Costs a full scan of oban_jobs on large tables (no index on attempted_at), so it is off by default
:discardedwindow / max3600 / 5jobs discarded in the window, per worker
:cancelledwindow / max3600 / 10jobs cancelled in the window, per worker
:cron_missingexpected%{} (off)worker => max seconds between insertions, e.g. %{"MyApp.Nightly" => 90_000}
:dead_workerswindow_daysnil (off)any positive integer number of days since a worker was last inserted (enqueued). 7, 14 and 30 are common examples; if you set known or discover: true without window_days, the window is 14. There is no fixed set of allowed values
:dead_workersignore[]worker names to skip (rare/seasonal jobs, or ones you have reviewed)
:dead_workersknown[]extra worker names to check, including those with no rows at all (workers that never ran, or were fully pruned)
:dead_workersoverrides%{}per-worker window in days, e.g. %{"MyApp.YearlyClose" => 400}
:dead_workersdiscoverfalsealso check Oban.Worker modules in loaded non-OTP applications (needs the host app started; mix queue_keeper.check and Release do not start it)
:dead_workersreport_short_historyfalseif the window is longer than the ledger's recording age (or, without a ledger, finished-job history), emit a warning instead of staying silent
:dead_workersuse_ledgertruewhen the opt-in ledger tables exist and recording has started, read last-seen times from them (cheap) instead of scanning oban_jobs. The check itself still only SELECTs; writing to the ledger is a separate, explicit QueueKeeperCheck.Ledger.attach/1
:persisted_jobsworkers[]deployed worker name strings (the trusted inventory). Compared as strings; never turned into atoms
:persisted_jobsprevious_workers[]extra worker names still considered deployed (rolling rename / rollout). Unioned with workers
:persisted_jobsqueues[]effective queue name strings for this Oban prefix
:persisted_jobspaused_queues[]operator-supplied list of queues known to be paused. The check does not read pause state from the cluster
:persisted_jobsdynamic_queues:unknown:unknown (default): queues not in queues are :insufficient_evidence, never unconfigured. :enumerated: the queues list is complete, so others are :unconfigured_queue
:persisted_jobsconsumers:unknown:unknown (default): never emit :no_active_consumer (one node cannot prove a deployment-wide gap). A list of queue name strings is a cluster-wide snapshot you supply; queues with leftover jobs not in that list may be :no_active_consumer
:persisted_jobsdiscoverfalseunion Oban.Worker modules in loaded non-OTP apps into the worker inventory (needs the host app started; mix queue_keeper.check and Release do not start it). If discover is the only worker source and it finds nothing, the check reports :insufficient_evidence instead of treating every job worker as missing
:persisted_jobsignore_workers / ignore_queues[]names to skip

:retry_storm counts, per worker, within the window:

  • retryable jobs whose last (failed) attempt started in the window (attempted_at; the query also bounds scheduled_at, which Oban sets after the attempt, so it can use the composite index),
  • executing jobs on attempt >= 2 attempted in the window (attempted_at),
  • discarded / cancelled jobs on attempt >= 2 discarded / cancelled in the window (discarded_at / cancelled_at),
  • with include_completed: true, completed jobs on attempt >= 2 attempted in the window (attempted_at).

A job that failed before the window and is still waiting out a long backoff is not counted. (Up to v0.2.0 every retryable job counted, whatever the window.)

A finding is :critical when the value is at least twice its threshold; :orphaned, :stalled and :cron_missing findings are always :critical. :dead_workers findings are always :warning (they are a hint about possible dead code, not a production outage).

:dead_workers is off until you set window_days (any positive integer), or you set a non-empty known list or discover: true. It uses last enqueue, not last execution: a worker that is still being enqueued is not dead code. When the opt-in last-seen ledger is present (see QueueKeeperCheck.Ledger), activity comes from that tiny table and the check stays silent until the ledger itself has been recording for the window; you do not need to raise the Pruner max_age. Without a ledger it falls back to max(inserted_at) on oban_jobs, and if the oldest finished job is newer than a worker's window that worker is not flagged. Workers listed in cron_missing.expected are skipped so the two checks do not double-report.

:persisted_jobs is off until you pass a worker inventory (workers, previous_workers, or discover: true), a queue inventory (queues or paused_queues), or a consumers snapshot. It is report-only: bounded SELECTs of nonterminal rows (available, scheduled including future, retryable, executing, and core suspended). One run/2 covers one prefix; run once per Oban instance. Worker and queue names from the database stay strings. Oban Pro-specific states or archive tables are not queried; Pro support beyond core suspended is untested and unverified.

Safety options (top level, not per check):

optiondefaultmeaning
:statement_timeout5000ms. Per statement server-side limit (Postgres statement_timeout, MySQL max_execution_time); also the basis of the client-side timeout on every engine
:lock_timeout1000ms. Postgres lock_timeout: give up rather than queue behind a lock (e.g. a migration)
:check_timeout30000ms. Client-side budget for one whole check (Postgres transaction / MySQL checkout holding one connection); the connection is dropped if exceeded
:read_onlytruePostgres: run each check in a transaction marked transaction_read_only, so the server rejects any write
:prefix"public" (Postgres), none elsewhereschema of oban_jobs (a database name on MySQL). Must be a plain identifier, [A-Za-z_][A-Za-z0-9_]{0,62}, or false for no prefix (use the connection's search_path)

Invalid or unknown options raise ArgumentError before any query runs.

Summary

Functions

Merge user options over the defaults, validating every value. Raises ArgumentError.

Safety options (:statement_timeout, :lock_timeout, :read_only) merged over defaults.

Validate an Oban prefix. Ecto already quotes it as an identifier (and rejects quote characters); this is a stricter allow-list so a prefix can only ever be a plain name.

Functions

build(opts)

Merge user options over the defaults, validating every value. Raises ArgumentError.

defaults()

guard(opts)

Safety options (:statement_timeout, :lock_timeout, :read_only) merged over defaults.

guard_defaults()

valid_prefix?(prefix)

Validate an Oban prefix. Ecto already quotes it as an identifier (and rejects quote characters); this is a stricter allow-list so a prefix can only ever be a plain name.