Central job queue worker – run, scheduling, retries
Steps of the worker called every minute: secret, locking, maintenance, clean-up, templates, seeds, NAV chains, time-boxed processing, retry rules, self-diagnosis and schedule times.
Overview
The single background entry point called every minute: it manages the cron_queue table and calls the controller or library matching the job type. Results: admin cron list, System → Async jobs, system log (channel cron), notifications and optional e-mails. It checks no function permission (system context); where a row carries entitlement_feature_key, the subscription right of the user who created the row decides.
Run steps (masterdata/cronqueue.run)
- If the module's cron secret is set, the
secretparameter must match (hash_equals), otherwise 403. Called by the server crontab every minute, or from the framework's cron list through thecron/cronqueueentry point (which injects the secret from the settings). - Lock file (
storage/logs/cronqueue.lock, 10 minutes): silent exit if an instance is running; heartbeat file; a shutdown handler removes the lock and logs even on a fatal error. - In maintenance mode only the update proceeds (
dlbtupdate->cronApply(35)), then exit. - Before 7:00 on Monday rows older than 30 days are deleted; daily doc cache clean-up; hourly Drive path refresh; cron self-healing (
dlbtcronhealth->healIfDue). enqueueDueTemplates(): runnable rows from due schedule templates (for a company group, for every company of the group),_schedule_idin the payload, template advanced (Dlbtschedule::nextRun).- Expired share folders deactivated (
expireShares); iPhone backup chain guard (getStuckChains);handleExpired(): expired pending rows deleted and rescheduled in catch-up mode. - Global seed (company_id = 0), if enabled and no row is pending:
email,email_commands,email_ai,taskdigest,contract_passthrough_scan,otpkelfo_ingest,contir_general,fxrate_sync,avgrate_daily,integrity_check,recovery_fee,interest_doc,subscription_lifecycle,quick_invoice,quick_image,nav_tax_debt,mail_sweep,update_check. - NAV sync seed: if the module's NAV sync switch is not 0 (default on), a
nav_invoice_syncchain at the next quarter-hour for every company with NAV credentials anddigest_status=1; broken chains restored; hourly diagnostic log. - Recovery of stuck invoices (
recoverOrphanPendingData): a newnav_invoice_datarow for NAV invoices left without items. - Time-boxed processing (default 45 s, 5–55), at most 200 rows: first Main Job rows, then pipeline rows, finally classic rows.
- Per row (
processClaimedItem): entitlement condition (dlbtentitlement->allowsFeatureKey; without rightskipped/entitlementand deletion);dispatch()ordispatchJob(); on success result saved, row deleted, result e-mail or log, next run scheduled, Main Job progress, optional completion e-mail. On error a friendly message, retry limit (permanent NAV error 1, transient network error 3, other 2), exponential back-off (30 s × 2^n, max 600 s), after the last attempt deletion and rescheduling; for NAV sync errors a notification to the company's authorised users.
Tables: cron_queue, job, notification, emailtask, company.
Self-diagnosis (masterdata/cronqueue.status)
From the browser, as plain text, read-only: last worker run from the heartbeat (over 180 s is an error) and lock state; NAV sync switch and interval; NAV companies (credentials, digest_status, seeded); the last 30 rows of nav_invoice_sync and nav_invoice_data; iPhone backup diagnostics; the crontab line to use. Protected by the cron secret (403).
Scheduling rules (scheduleNextRun)
| Rule | Job types |
|---|---|
| one-off, event-driven (no rescheduling) | nav_invoice_ref, doc_zip_unpack, doc_recognise, content_translate, doc_download, update_apply, contract_passthrough, iphone_backup_*, mail_message, mail_batch, email_task, doc_text, gpt_workflow |
| daily time (immediate catch-up run if missed) | subscription_lifecycle 00:20, avgrate_daily 03:00, quick_invoice 03:45, quick_image 04:00 (+5 min if candidates remain), otpkelfo_ingest 05:40, nav_tax_debt 06:10, fxrate_sync 13:00 |
| hourly | integrity_check :07, recovery_fee :10, interest_doc :15; contir_general +60 min |
| minutes | email, email_commands +1 min, email_ai +2 min, contract_passthrough_scan +2 min, mail_sweep +5 min |
| special | taskdigest: next Monday 05:30; nav_invoice_sync: next interval boundary (default 15 min); update_check: the configured interval in hours (default 6) + installation-specific 0–59 min + 0–9 min random |
| default | tomorrow 05:00 + position in the order × 2 min, but at least 2 min after the last row of the day |