Concepts
Runs and attempts
A run is one execution of a task for one payload. It moves through a small set of statuses, and each try at it is an attempt.
Statuses#
Every run has one of seven statuses. The last three are final.
| Status | Meaning |
|---|---|
delayed | Triggered with a delay or a debounce, and waiting for its time. It holds no worker and no queue slot. At its time it becomes queued. |
queued | Accepted and waiting for a worker. A retried run is queued again, and waits out its retry delay first. |
running | An attempt has started. |
waiting | A workflow is waiting on a step: one child run or a batch of them, a timer or an event. It holds no worker. |
completed | The handler returned. The run's output holds the result. |
failed | The run used its attempts, a child it called with ctx.callTask failed, or it could not be placed or started in time. error says why. |
cancelled | Someone cancelled the run, or a run above it. |
Statuses are lower case, and cancelled has two Ls.
Attempts#
An attempt is one try at a run on one worker. A run's attempts are listed with it, oldest first:
| Field | Meaning |
|---|---|
epoch | The attempt's number in the run, from 1. |
status | running, completed, failed, suspended (a workflow reached a new step) or cancelled. Lost workers explains the rest. |
pool | Where it ran: private, cloud, or burst-simulated on a local control plane. |
executor | How it ran: docker, native-trusted or in-image. |
workerId | The registered worker that ran it, or null for the control plane's own pools. |
startedAt, finishedAt, elapsedMs | Timing. |
A task's run usually has one attempt, plus one per retry. A workflow's run has one attempt per step it took, because each step ends an attempt with suspended and the next step starts a new one.
Retries#
A failed attempt (the handler threw) puts the run back in the queue after a delay: 1 second, doubling, each multiplied by a random 1 to 2 and held to at most 60 seconds, unless the task's retry says otherwise. While it waits, the run's retry field holds attempt, the number of the attempt that starts next, and at, when it may start. No worker takes it before then. The run fails when max_attempts attempts have failed, or at once when the handler throws AbortTaskRunError or runs past its timeout_ms after it started.
Some attempts never start: the worker could not load the deployment's image, or the run's variables could not be decrypted. Those are deferred. A deferral consumes no attempt. The run waits 1 second, then 2, doubling up to 60 seconds between tries, and fails if it still cannot start an hour after the first deferral.
Capacity waits#
A run can be accepted while no worker its placement allows can fit it yet, for example before a burst machine exists. It then carries a capacityWait with a reason, a since and an until, and the console shows it as Waiting for compute. The wait clears once fitting capacity appears. If none does by until (an hour by default), the run fails without an attempt and with the reason.
While every machine the run may use is busy with other runs, until is null: the run waits with no deadline and starts once one frees up. Once the machines are no longer all busy, the wait gets an until an hour away again.
A run larger than its environment allows for its placement is refused when you trigger it, with a CapacityError.
Cancellation#
runs.cancel cancels a run and every unfinished run below it. A running attempt is told to stop, and its process is ended. A workflow waiting on a cancelled child from ctx.callTask fails. One waiting with ctx.triggerAndWait or ctx.batchTriggerAndWait gets a RunCancelledError result for it and carries on.
A run cancelled while an attempt of it was executing runs its onCancel lifecycle hooks afterwards, in a hook run below it. Cancelling a run never stops a hook run below it, so the failure and cancel hooks of the runs you cancel still run.
Lost workers#
A worker renews a lease while it runs an attempt. When a worker stops answering, Bok Joy does not assume its process is gone. The attempt is marked cleanup_pending and held until the worker proves it stopped, the burst machine it ran on is confirmed destroyed, or an operator releases it. Only then is it marked expired, and the run retries. The expired attempt counts against max_attempts.
That is why a run whose worker vanished can take a moment to retry. Bok Joy never runs a second copy of an attempt it cannot account for.
When the lost attempt was the run's last, the run fails, and its onFailure and onComplete hooks run in a process of their own. If the attempt had already run its success hooks, those ran too: see When both onSuccess and onFailure run.
Where to read runs#
- In code:
runs.retrieve,runs.pollandruns.subscribe(Read, cancel and follow runs), andruns.listto find runs by status, task, tag or time (List runs). - Over HTTP:
GET /v1/runs/{id}andGET /v1/runs(Runs API). - In the CLI:
durable-compute inspect <id>,tree <id>,watch <id>andlist. - In the console: the run list and a live trace of each run.