prop/lib/microwaveprop/workers/propagation_prune_worker.ex
Graham McIntire 504f5147f6
fix(propagation): hourly grid chain preempts MRMS/prune backlog
The :propagation queue (2 slots) is shared by PropagationGridWorker,
MrmsFetchWorker (every 2 min), and PropagationPruneWorker (every
15 min). Oban dispatches priority-then-FIFO, so a post-deploy
MRMS/prune backlog could delay the hourly chain step until the
siblings drained.

Set PropagationGridWorker priority: 0 explicitly and drop the two
siblings to priority: 5 so new chain steps always jump ahead.
Backfill workers live on separate queues (:hrrr, :weather, :terrain,
:iemre, :narr, :radar, :mechanism) and already don't interact with
the predictor.
2026-04-19 08:42:22 -05:00

28 lines
970 B
Elixir

defmodule Microwaveprop.Workers.PropagationPruneWorker do
@moduledoc """
Standalone worker that prunes stale rows from `propagation_scores`.
Pruning used to be tacked on to the end of `PropagationGridWorker.perform/1`,
which meant it only ran after a successful grid compute. When the compute
worker was being killed mid-run (OOM / SIGTERM), prune never ran and the
table grew unbounded. Running prune on its own cron keeps the table healthy
regardless of the compute worker's state.
"""
use Oban.Worker,
queue: :propagation,
# Lower priority than PropagationGridWorker so the hourly chain
# never waits behind a pending prune on the shared :propagation
# queue (2 slots).
priority: 5,
max_attempts: 3,
unique: [period: 300, states: [:available, :scheduled, :executing, :retryable]]
alias Microwaveprop.Propagation
@impl Oban.Worker
def perform(%Oban.Job{}) do
Propagation.prune_old_scores()
:ok
end
end