Skip to content

Runs, history and notices#

Every time a scheduled task runs, at its time or by hand, a run is left in the history with its result and its steps. This page explains how to read the history, how to stop a run in progress, how to receive email notices and what happens with several server instances.

Before you start#

  • You see the runs of the kinds of task you manage: workbook recalculations with Workbook administration; groups and procedures, with System administration. On restricted connections, only whoever administers the metadata.
  • Email notices need a mail server (see Configuration and Mail).

The history#

Last runs, in Scheduling, gives those of the connection; Runs, in a task's detail, its own. Each row has:

Column What it shows
Start When it started.
Task The task (only in the connection's history).
By Scheduled or Manually, and on whose behalf.
Outcome The status, with its icon.
Duration How long it took or has been going.
The run history of a task with one run expanded showing its steps: pre-procedure, two workbooks and post-procedureThe run history of a task with one run expanded showing its steps: pre-procedure, two workbooks and post-procedure
The run history of a task with one run expanded showing its steps: pre-procedure, two workbooks and post-procedure

Expand a run to see its steps: Pre procedure, each Workbook (with its attempts) or Document, the File export of each workbook that has one (with View the files), Procedure and Post procedure, each one with its result and its message.

Outcome What it means
Running It is running.
Succeeded It finished well. A recalculation without documents that keep data finishes well saying so: “No document of the workbook keeps data: there is nothing to recalculate”.
Error It failed. The step's message says why.
Not done It was due, but the previous run was still going: they do not overlap. The message says which one is still running and on which instance. It is notified as an error.
Stopped Someone stopped it (“Stopped by “login””). It is not a failure.

The history is kept for 90 days (ecenter.scheduling.history) and each run is also recorded in the audit as Scheduled run, with the Scheduled task channel and the reference sch-run:<run>. To see everything a run calculated (its queries, its jobs), open its entry in the audit and click Include next to the channel (see Search, filter and export).

Run now#

Run now, in a task's detail, launches it right away, in your name, without waiting its turn and without changing its next run. If it is already running, another is not launched (409: “The task '…' is already running”).

Stop a run#

  1. Open the running task and click Stop.
  2. Read what will happen and confirm with Stop:
    • a procedure: “The call to the procedure in the database is canceled, which rolls back what it had not committed”;
    • a group: “The workbooks being recalculated are canceled and the post procedure is not called”;
    • a recalculation: “The documents being recalculated are canceled.”.

The run ends as Stopped, in your name. The workbooks already recalculated stay recalculated, and what a procedure had committed on its own stays done. If it finished just before the request arrived, it stays as succeeded (“(it was asked to stop when it was already finishing)”). It is recorded in the audit as Scheduled run stopped, with on whose behalf it was running.

With several instances, it is stopped by the instance that has it running: right away if it is the one that receives the request and, if it is another, on its next round (a few seconds).

Email notices#

The scheduler can notify the result of each run by email. It is configured on the server:

Property Default What it is
ecenter.scheduling.notifications.mode NONE NONE: no notice. ALL: all runs. FAILURES: those that fail or were not done (one stopped by hand is not a failure).
ecenter.scheduling.notifications.recipients (none) The addresses. Without recipients there is no notice.
ecenter.scheduling.notifications.from ecenter.notifications.from The sender.
ECENTER_SCHEDULING_NOTIFICATIONS_MODE=FAILURES
ECENTER_SCHEDULING_NOTIFICATIONS_RECIPIENTS=sistemas@example.org

The subject gives the result, the task and the connection: “[Empowerment Center] Failed “Cierre comercial diario” (Demo · Distribuciones Ibéricas)”, or “Finished”, “Not run”, “Stopped”. The body gives the task and its kind, the connection, on whose behalf (or who ran it by hand), the start, the end, the duration, the result and each step with its result, its attempts and its message.

The alert for tasks that fail repeatedly#

Even without email notices, the operations console opens the Scheduled task failing repeatedly alert when an active task fails its last 3 runs in a row (ecenter.operations.alerts.scheduled-failures), with its name, its kind, its connection and the last reason. Runs not done and those stopped by hand neither count nor break the streak. It resolves itself when the task finishes well, is deactivated or is deleted. See Operational alerts.

Several instances#

ECenter is designed for one instance, but scheduling works the same with several:

  • Only one instance reviews the tasks at a time, with a lock in the own database, and each task is launched by the one that manages to move it to its next run. It does not run twice.
  • Only one run in progress per task, also across instances: the database guarantees it. At its time, a run that coincides with another in progress is left as Not done.
  • Each run knows which instance it belongs to (ECENTER_INSTANCE_NAME). On startup, each instance treats as interrupted only its own runs left in progress; those of another carry on, because they are that one's.

Important

Give each instance a fixed name with ECENTER_INSTANCE_NAME (deploy/compose.yaml sets ecenter-1). If an instance is removed for good with runs in progress, those runs block their task until an instance with the same name starts, which treats them as interrupted.

Launch a task from another system#

An external process (an ETL that finishes, an orchestrator) can launch specific tasks without a session, with a service credential with the Scheduled tasks scope. Whoever has System administration creates it, in the name of a holder with Workbook administration, and it names the tasks it can launch. The program sends the secret in the Authorization: Bearer … header:

Request What it does
GET /api/scheduling/v1/tasks The credential's tasks, with their status.
GET /api/scheduling/v1/tasks/{id} One of them.
POST /api/scheduling/v1/tasks/{id}/runs Launches it: 202 with the run and its address in Location; 409 TASK_RUNNING if it is already running.
GET /api/scheduling/v1/runs/{id} The status of a run launched with the credential.
POST /api/scheduling/v1/runs/{id}/stop Stops it; 409 RUN_FINISHED if it had already finished.

A task the credential does not name responds 403 NOT_ALLOWED. The run goes on behalf of the credential's holder, and its history says Through the API. If the credential is revoked, or its holder is disabled or deleted, the runs it launched that are still in progress are stopped.

It can also be launched with an application session of a user who has the privilege for its kind: sign in at POST /api/auth/login and send the session cookie and the X-XSRF-TOKEN header (given by GET /api/auth/csrf), like the frontend.

Request What it does
POST /api/scheduled-tasks/{id}/run Run now: 202 with the run; 409 if it is already running.
GET /api/scheduled-runs/{id} The status of a run with its steps.
POST /api/scheduled-runs/{id}/stop Stop: 202; 409 if it had already finished.

Configuration#

Property Default What it is
ecenter.scheduling.enabled true false: nothing is launched at its time (Run now still works)
ecenter.scheduling.tick 15s How often tasks are reviewed
ecenter.scheduling.zone the server's The time zone of the schedules, for example Europe/Madrid
ecenter.scheduling.max-running 4 Tasks running at once on an instance
ecenter.scheduling.recalc-timeout 2h Each attempt to recalculate a workbook
ecenter.scheduling.procedure-timeout 2h A scheduled procedure
ecenter.scheduling.step-timeout 30m A group's pre- or post-procedure
ecenter.scheduling.history 90d How long the history is kept
ecenter.scheduling.instance-name ECENTER_INSTANCE_NAME or the host name The instance of each run
ecenter.scheduling.notifications.* NONE Email notices (above)

See also#