PhoenixKit 2.48.0: Job runs you can watch, pause and cancel
PhoenixKit 2.48.0 adds job runs: long background work an admin can watch, pause, resume and cancel from the Jobs page, which is now part of core and always on.
Job runs
A job run is a lasting record of one piece of background work: its state, progress, who started, paused or cancelled it, and its history. Oban carries it out batch by batch. Pause and cancel take effect at the end of the current batch. A sweeper job every five minutes recovers runs whose batch died, and finished runs are deleted after job_runs_retention_days, 90 by default. Modules can add their own kinds of run.
The first kind is the photo capture-date backfill, which can now be paused, resumed and cancelled.
The Jobs page
The Jobs page gets a Runs tab, the default, with state and module filters, progress bars, the controls each viewer may use, a drawer with one run’s history, and live updates. Oban’s own table moves to the Queue tab. The page warns when runs are waiting and the sweeper has not been seen for 15 minutes.
Jobs is no longer a module to switch on. It leaves the Modules page, and controlling runs needs the new jobs.manage permission. Admin gets it automatically; other roles that could view Jobs keep viewing only.
Fix
A module’s email text came out in the sender’s language instead of the recipient’s. It now follows the recipient.
Upgrading
Run mix phoenix_kit.update for V207. It also adds the sweeper and prune jobs to your Oban crontab.
Full release notes: PhoenixKit 2.48.0
2.48.0 · 3 October 2026
Added
PhoenixKit.Email.Layout.render_parts/2: the site’s email header and footer on their own, for a module that builds its own document (#893). Chosen by the same code as the layout (group, then shared, then core; the reader’s language; a blank file counts as missing), and without:pathsit reads the host’s template directories like every email. See the email templates guide.- Job runs: long background work an admin can watch and control (V207,
PhoenixKit.Jobs). A run is a durable record of one piece of work — its state, progress, who started, paused or cancelled it, and its history — that Oban executes batch by batch.Jobs.start/pause/resume/cancel/retrytake the signed-inScopeand checkjobs.manageand the kind’s own permission against the active role; boot, cron and scripts useJobs.System.start/3, andJobs.run_inline/3runs the same kind in a script without Oban. A module adds a kind withuse PhoenixKit.Jobs.Kindandjob_kinds/0(orconfig :phoenix_kit, job_kinds: [...]); the engine owns the rest.- Every transition is one transaction: the row is locked, the change written, the next batch’s Oban
job inserted and the Activity entry made together, so a crash cannot leave a run with no job or
a change with no history. A batch holds a claim on the run; an Oban job carries the generation it
was made for and an older one does nothing. Pause and cancel while a batch executes are requests
(
pausing,cancelling) the batch settles at its checkpoint; resume is refused while one drains; a trigger that arrives during the last batch starts a fresh pass instead of being lost. - A sweeper (
Jobs.SweepWorker, every five minutes) releases a dead batch’s claim, fails a run whose Oban job was discarded or cancelled, and rescues a lost dispatch up to three times;Jobs.PruneWorkerdeletes finished runs afterjob_runs_retention_days(default 90).mix phoenix_kit.updateadds both to the host’s crontab.
- Every transition is one transaction: the row is locked, the change written, the next batch’s Oban
job inserted and the Activity entry made together, so a crash cannot leave a run with no job or
a change with no history. A batch holds a claim on the run; an Oban job carries the generation it
was made for and an older one does nothing. Pause and cancel while a batch executes are requests
(
- The Jobs page has a Runs tab (the default), with state and module filters, progress bars, the controls each viewer may use, a drawer of one run with its history, and live updates; Oban’s own table is the Queue tab. It warns when runs are waiting and the sweeper has not been seen for 15 minutes. The tab, filters and opened run are in the URL.
- The capture-date backfill is the first kind (
storage.capture_date_backfill,media.manage): it shows on the Runs tab with its progress and can be paused, resumed and cancelled. The mix task runs the same kind inline.
Fixed
- A feature module’s email text came out in the sender’s language, not the recipient’s (#892).
RecipientLocale.in_locale/2now also installs the recipient’s base language as the process locale for the duration, which is what a module’s own Gettext backend reads. - Recovery of job runs is decided under the run’s row lock. The sweeper lists candidates; the
engine (
Engine.recover/4) reloads each and decides from the run as it is then, so a slow sweep can no longer undo a newer dispatch, steal a live claim or charge the rescue budget twice. A rescue or an outside failure of a run a batch holds is refused by the state machine. - A script’s claim (
Jobs.run_inline/3) is a lease the sweeper respects (new columnclaim_owner, an hour, renewed byJobs.heartbeat/1); a dead script’s run is taken back when the lease runs out. Inline execution now waits out{:snooze, s}andschedule_in:. - An obsolete Oban delivery stays inert even when its kind has gone: the worker claims first and only then looks the kind up.
- Job runs work on a named Oban schema: recovery,
Jobs.get_job_stats/0and the Jobs page read Oban’s table through its configured prefix, and check a job is the run’s own. - The engine refuses to run inside a caller’s transaction (
{:error, :in_transaction}), so no event oron_finish/2escapes a rollback;Jobs.start/4documents{:error, :raced}as “not recorded”. - A script that asks its next batch to wait keeps its run through the wait (
wake_at, and the script stays the run’s owner between batches): the sweeper no longer reads the wait as a lost dispatch, and a rescue carries what is left of a delay into its dispatch. - A script’s wait belongs to the script that asked for it:
Jobs.run_inline/3carries an owner identity (owner_token) between its batches, another invocation is refused while it stands, and a rescue keeps a delayed run’s due time. - Without an Oban instance the sweeper, the stats and the Jobs page no longer guess: a run that never had a dispatch keeps its rescue budget, nothing falls back to the default schema’s table, and the Queue tab says Oban is not running on that node.
- The “counts may be approximate” notice follows
interruptions, a new counter of batches cut off and run again (an Oban retry, a sweeper release, a dead script’s takeover); the Mix task prints it. - The Jobs page’s sweeper warning and Runs badge cover all runs, not the filtered page; the open run refreshes with the table; the filters use the core select.
Changed
- Jobs is no longer a module you switch on: it is always on. It leaves the Modules page;
jobsis a core section key andjobs.managea sub-permission that is granted to Admin at boot and not backfilled to existing holders ofjobs, who keep viewing.Jobs.enabled?/0,enable_system/0anddisable_system/0remain, deprecated, astrueand no-ops. - The capture-date backfill’s worker starts a run instead of walking the library itself; its old job shape still arrives and does the same.
i18n
- The Jobs page’s new strings (the Runs tab, its controls, history and notices) in all seven locales.
PhoenixKit 2.48.0. Install or update: {:phoenix_kit, "~> 2.48"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.