The scheduler: templates, instances, self-healing and permissions

Data model of the single scheduler, the relation of template and instance rows, the supported job types, the rules for saving and row actions, self-healing and the content scope.

The system has a single scheduler. The template rows of the queue (is_template = 1) define WHEN for a company, a company group or the system; the catalog worker (masterdata/cronqueue.run) inserts instance rows (is_template = 0) from due templates and processes them. Timing is calculated by the shared schedule calculator (minute, hour, day, week, month; Europe/Budapest).

Data model

Table names carry the installation's own prefix in the database.

TableRoleMain fields
cron_queuetemplates and instancesjob_type, company_id, company group, is_template, next_run, status, payload (e.g. email_task_id, check_code)
cron_healthopen self-healing findingsjob type, issue, state
companytarget companyread only

Saving and row actions

  1. Job types on the form: taxaccount, missingtaxreturn, email, email_commands, email_ai, taskdigest, taskrecurring, nav_invoice_query, nav_invoice_sync, nav_invoice_data, email_task, integrity_check, content_translate.
  2. Target: company, company group, or for system jobs (email*, taskdigest, integrity_check) the system. Parameterised jobs: email_task (company and timing come from the task), integrity_check (the check code).
  3. Optional result e-mail (mail_notify 0–2, channel and template from the mail module per client).
  4. After saving: next run calculated, row read back, mail setting saved. For an instance row only next_run can change.
  5. runnow: immediate instance row(s), one per member company for a group; the template's next_run is unchanged. stopselected: template → deactivate, instance → delete. delete: physical delete, the mail module setting is deactivated.
  6. Every action writes to the cron log channel.
  7. enqueueDue(): public method of the runner bridge; inserts rows from due templates and advances next_run; permission: edit.

Self-healing

The health endpoint runs what the worker runs every 10 minutes: restores broken self-sustaining chains, resets rows running for more than 60 minutes, fixes drifted e-mail task schedules, cleans orphaned templates and rows of deleted companies. It reports rows dead after 3 attempts, items waiting more than 6 hours and unknown job types. Reply: number of repaired and open items. The service library writes its own SQL. Missing table: error_health_schema.

Errors

error_job_type, error_target, error_object, error_object_no_company, error_duplicate_template, error_mail_template, error_save_not_created, error_next_run.

Permissions

KeyClassEndpoints
listunclassifiedlist, company picker
addno catalogue row, so edit decidessave as new (canSave)
editnot in the seedsform, runnow, enable, disable, mail options
deletenot in the seedsdelete; stop and stopselected with delete or edit
statusdeleteBASEin the seed but without an endpoint; behaviour cannot be determined
healthpermission input onlyself-healing
debugnot in the seedslist SQL

Content scope: the list filters by filter_allowed_ids; write endpoints by idsInScope and scheduleInScope; system-level rows cannot be managed by anyone but the super administrator.