Background jobs for operators
The queue (ADR 0150) lives in three tables of the tenant database: erp_job (pending, running,
held and dead jobs), erp_job_run (history) and erp_job_item_failure (items that failed alone).
Any worker may claim any job of a kind its binary registers; there is no scheduler process and no
leader. A job’s lease is measured on the database clock, so clock skew between nodes cannot make
two workers own one job.
Configuration delivery boundary. The server has optional in-app job composition. Whether a particular dev/testing deployment has enabled it is not established by this guide. The declared database settings below govern new enqueues and claims on database-backed nodes. Running jobs retain their admitted limits.
Settings
Section titled “Settings”Every setting has a default, a floor and a hard bound. A value outside them is refused by name
the setting (jobs.poll_interval_secs = 0 is outside 1..=300); zero never means unlimited.
jobs.wake_slack_ms = 0 wakes only exactly-due work; it is a threshold, never unlimited capacity.
Capacity settings belong to the node; Shared policy comes from the tenant database. Node admission
checks provider/catalogue compatibility while allowing saved policy to change without a restart.
| Setting | Default | Allowed |
|---|---|---|
jobs.workers (node) | 4 | 1 to 256 |
jobs.workers_per_db (node) | 2 | 1 to jobs.workers |
jobs.max_running_per_db | 16 | 1 to 4,096, divided by the live workers |
jobs.claim_batch (node) | 8 | 1 to 256 |
jobs.lease_secs | 90 | 15 to 3,600 |
jobs.reap_interval_secs | 15 | 1 to 300 |
jobs.poll_interval_secs | 5 | 1 to 300 |
jobs.notify_interval_ms | 1,000 | 50 to 60,000 |
jobs.wake_slack_ms | 1,000 | 0 to 60,000 |
jobs.max_chunks_per_run | 10 | 1 to 10,000 |
jobs.run_budget_secs | 120 | 1 to 3,600 |
jobs.job_deadline_secs | 900 | 10 to 86,400 |
jobs.chunk.default.{lock,statement,transaction}_ms | 5,000 / 30,000 / 60,000 | lock below statement below transaction |
jobs.chunk.maintenance.* | 5,000 / 300,000 / 600,000 | same |
jobs.backoff_base_secs, jobs.backoff_cap_secs | 10, 3,600 | 1 to 3,600; base to 86,400 |
jobs.max_attempts | 10 | 1 to 100 |
jobs.payload_max_bytes | 65,536 | 1,024 to 65,536 |
jobs.progress_max_bytes | 1,048,576 | 4,096 to 1,048,576 |
jobs.max_item_failures_per_job | 10,000 | 1 to 100,000 |
jobs.history_days | 7 | 1 to 3,650 |
jobs.dead_retention_days | 30 | 1 to 3,650 |
A job’s lease is max(jobs.lease_secs, its class's transaction timeout + 10 s), so a running chunk
cannot outlive its lease unnoticed.
Stored shared policy
Section titled “Stored shared policy”Settings administrators open Technical > Automation > Background Job Settings and find the
Background Jobs block. These values are Global within the current tenant database, never per company.
Each Shared internal key maps to base. plus its complete name, preserving nested timeout segments.
Defaults and ranges are shown with units. Use default edits the field; Save audits the ordinary
value write, while Discard reloads stored values. Defaults are returned for absent rows without seeding
fake values or audit history. Installation/upgrade preserves saved choices.
A save validates the entire resulting group, including unchanged members. Both timeout classes require lock < statement < transaction; backoff base must not exceed cap. Invalid batches, stale revisions and audit failures persist no prefix. A conflict requires reloading and reviewing the other writer’s changes. Corrupt stored values fail by setting name; they never silently restore defaults.
Saved values govern new enqueues and claims without restart. Active runs keep their admitted snapshot. The served request ORM, isolated owner runner and attachment recovery use the same database authority. Node workers/workers_per_db/claim_batch/run_in_app are excluded from the database editor because they describe local capacity and placement. Generic queue/history CRUD remains refused.
Connections and NOTIFY
Section titled “Connections and NOTIFY”Per process and database a runner uses up to jobs.workers_per_db pool connections for claims and
chunks plus the one shared signal-listener connection. Worker connections are
processes x databases x workers_per_db (plus one listener each); count them next to the
connection budget of the server. Database-backed policy adds a separate read pool of up to
workers_per_db connections per process/database. The owner runner shares that reader pool;
an operator recovery command uses one separate read connection.
Enqueues send at most one payload-free NOTIFY erp_jobs per jobs.notify_interval_ms per process
and database, and none when this process is the only node. The cluster-wide budget of notifying
commits is shared with the signal, outbox and bus channels, so keep the interval at its default
unless you have measured the cost. A lost or suppressed notification costs latency, never a job:
every runner also polls every jobs.poll_interval_secs.
Dead letters, history, retention
Section titled “Dead letters, history, retention”A job that fails for good stays in erp_job with state = 'dead', an error code and a bounded
message (no payload text). An administrator holding the jobs.admin capability can requeue or
discard it. Dead letters older than jobs.dead_retention_days move to history as dead_expired
(the move is logged at warn with the count), history older than jobs.history_days is deleted
in batches of at most 10,000 rows. Both run as core schedules once a runner is up.
Attachment schedules. Installing or upgrading base, and every erp server start, creates the
recurring rows of the attachment maintenance kinds (base.attachment_gc,
base.attachment_clean_staging, base.attachment_reconcile) that are missing; existing rows keep
their next run time. With jobs_run_in_app = true the in-app runner excludes the elevated attachment
kinds (ADR 0165 D5, ADR 0185): their rows stay ready and are never claimed. Discard old attachment
dead letters instead of requeueing them (a requeue collides with the live row on the dedup index). They show up in
the job list as ready and run only where the isolated maintenance runner is enabled with
attachment_maintenance_run_in_app = true (attachment store).
Generic partition upkeep
Section titled “Generic partition upkeep”The native server maintains every installed partitioned model at startup and on an owner-role timer. This work runs independently of the ordinary job runner and its enable switch. It has no queue execution row yet. The closed audit/outbox event-table timer remains independent, including each node’s audit-store readiness refresh.
The database-wide system parameter base.partition_upkeep_interval_secs has default 3600
seconds and an allowed range of 60 through 3600. The Technical parameter form displays the
range; administrator access to that screen remains unavailable until the separate parameter-access
security work is delivered. An operator can use the trusted owner path meanwhile. Invalid edits
are refused by name. Absent or empty values restore the default. Startup
refuses invalid stored policy or incomplete upkeep. Later policy corruption skips that tick
and emits a named error; recovery is retried at the last valid cadence. Committed changes are
read at the next scheduled wake. There is currently no general event-maintenance health
screen; inspect operator logs for failed steps and deferred drops.
Budget one additional owner connection per serving process and tenant database. The fixed one-slot pool serves this serial operation only; requests retain their existing runtime role and receive no DDL privileges. Each run uses the database’s UTC time, the current installed registry, and the partition engine’s existing per-table locks. Multiple nodes can attempt upkeep safely. A lost connection releases locks; later runs recover interrupted work. Missing partitions continue to refuse inserts instead of routing them to a catch-all table.
Administration UI
Section titled “Administration UI”Administrators holding the jobs.admin capability (granted to base.group_system by default)
manage jobs and inspect runs through the technical views:
- Technical > Automation > Background Jobs (
ir.job): list and form views showing kind, state, priority, attempts, scheduled time, next run, deadline, worker, and duration. Action buttons allow operators toHold(pause ready job),Resume(unpause held job),Cancel(stop queued job),Requeue(retry dead job), andDiscard(abandon dead job). Generic record modifications (create,write,unlink) are refused: queue rows are lifecycle-managed only. - Technical > Automation > Job Runs (
ir.job.run): read-only execution history displaying job UUID, worker identifier, start and finished timestamps, duration, chunk count, and outcome.
Privileges
Section titled “Privileges”The runtime role holds SELECT, INSERT, DELETE on the three tables and UPDATE only on the
lifecycle columns of erp_job (never the identity, kind, payload, keys or stored principal) and
on the error columns of erp_job_item_failure. erp db publish-grants sets this, and the server’s
start check verifies it as the runtime role. A single runtime role means the in-process runner can
change leases; a dedicated worker role is a later hardening.
Migrating process policy
Section titled “Migrating process policy”Before enabling the database source, inventory any custom embedding’s Shared jobs.* process overrides.
A Settings administrator must review those values and save them through the Global Background Jobs group
(or the same audited ir.config.setting CAS service). Remove every explicit Shared process override, including values equal to defaults, before starting
the database-backed node. Startup never imports values and never makes the first node the policy writer.
The served TOML parser does not expose a general Shared jobs.* table; do not add one as a migration shortcut.
Node workers, workers_per_db and claim_batch remain local. The existing jobs_run_in_app server option is
the source of the effective run_in_app choice. Native composition allocates a separate bounded read pool
sized from the node workers_per_db capacity; it is shared by policy readers for that served generation.
Enqueue transactions cannot consume that pool’s connections. Missing declarations/schema, invalid values
or an unavailable reader refuse new admission and emit an error. Repairing committed policy lets bounded
polling resume admission, even after a lost notification. Existing active leases are not shortened.
Old attachment owner markers have no admitted deadline recorded. Recovery therefore waits the jobs deadline catalogue’s hard envelope, plus the existing check for a live ownership-singleton lease. Lowering the current deadline cannot prove older work finished. This conservative recovery wait can exceed the current configured deadline; operators must still inspect and confirm recovery normally.
The first database-authority deployment changes jobs compatibility identity. Use the existing controlled rollout window or drain and replace the previous binaries; keep build/addon/readiness admission enabled.