Expand description
Giving tasks to workers and handling what workers report about them (see archive/PROJECT.md, Task assignment and Task rejections).
- Assign: ready tasks, oldest ready first, each to the worker chosen by
Workers::pick; the assignment is stored beforeAssignTaskis sent. Startedmeans accepted. For an attempt that was taken back or ended, the worker is told to kill it.Rejectedtakes the assignment back (it isn’t a try): a temporary reason queues the task again at once; “code not there yet” afterCODE_RETRY_DELAY, andunschedulableonce every eligible worker said so and the code has been missing for the code wait; a worker-specific reason leaves that worker out for the task, which becomesunschedulablewhen every eligible worker rejected it, until the set of workers changes or a user retries it. A task being cancelled iscancelledinstead.- Only the newest code runs: a task goes only to workers that have its root at the root’s current hash (and sends that hash for the worker to check), with a schedr version at least its parse’s.
- A task that waits shows why: no active worker serves its queue, none is recent enough, none has the newest code yet, every one rejected it, or no free slot.
Finishedis stored (the first one counts) and always acknowledged.- An attempt with no
Startedwithin the worker lease endsassignment_expiredand the task runs again without using a retry; a lost worker’s attempts endlost.
The dispatcher only builds messages; the gRPC server sends them (milestone 1.14).
Structs§
- Dispatcher
- Tasks given to workers and their reports handled.
- Memory
- The dispatcher’s memory that a worker’s message changes (see
Dispatcher::memory). - Outgoing
- A message for one worker.
- Read
Back - How a commit cut off by the time limit or a lost connection is read back: whether the work
is stored, checked at once, then every
intervalfor up towindow, since a server slow enough to have cut it off may still be committing it (read_back_window,read_back_interval). Never seen meanwhile: not stored (a stored round’s attempts then never left the master: taken back with their worker’s return or loss, B240). The master holds its lock meanwhile: only after a commit cut off, a database incident.
Enums§
- Dispatch
Error - Why a dispatcher operation failed.
- Kept
Results - What is done with the task results kept for a worker’s attempts as it goes.
- Witness
- What a write did to an attempt, for a commit cut off to be read back by.
Constants§
- ASSIGNMENTS_
PER_ ROUND - The most assignments a round makes (a few statements each, about 5-13 ms in stress runs): thousands of ready tasks and free slots go over a few rounds, the longest ready first (B18). Steady state stays under it (about 16 a round in scenario 1).
- CODE_
GONE_ ERRORS - Error kinds of an attempt whose task or DAG file isn’t in the code it ran with; when the DAG changed after the run started, its error summary says how.
- CODE_
RETRY_ DELAY - When a task whose code wasn’t on the worker yet is tried again: about the git-sync interval plus the settle time.
- DAG_
IN_ CONFLICT - Why a task of a DAG in an ID conflict waits (B193).
- DEFAULT_
CANCEL_ GRACE - The grace time between SIGTERM and SIGKILL when an attempt is cancelled (master configuration; this is the default).
- DEFAULT_
CODE_ WAIT - How long a task’s code may be missing on every eligible worker before the task is
unschedulable([master] code_wait). - DEFAULT_
HANDED_ CALL_ MIN - The least an
@sensor(wait_for=...)’s call gets once it is handed a run that ended within itsmax_wait, though little or none of that is left (SCHEDR_HIDDEN__MASTER__HANDED_CALL_MIN). - DEFAULT_
LEASE - The worker lease, by default: how long a replaced incarnation’s attempts are held
(decision 443); the master uses its own (
Dispatcher::with_lease). - DEFAULT_
SET_ ASIDE - How long a task whose assignment failed on its own is left out of the rounds before it is
tried again, unless set otherwise (see
Dispatcher::assign_into). - EXPIRIES_
PER_ ROUND - The most assignments a round takes back as never started (B18).
- INLINE_
INPUTS_ LIMIT - Inputs up to this size travel inside
AssignTask, while the whole message stays within what a worker takes (B157); bigger ones are fetched separately. - INPUTS_
TOO_ LARGE - The error kind of a task whose inputs are over
MAX_INPUTS. - INPUT_
MISMATCH - The error kind of a task whose inputs don’t fit its parameters (the runner’s too); not retried.
- LATE_
CLEANUP_ FAILED - Why a run is a yellow success: a cleanup after its end failed (decision 309).
- MAX_
INPUTS - Inputs over this size make the task fail (
inputs_too_large, never retried). - PENDING_
PER_ ROUND - The most pending reasons a round writes for the tasks past its cap (decision 481): one statement; a longer backlog gets them over the next rounds.
- REASONS_
PER_ ROUND - The most waiting reasons a round writes (each a statement, about 3.5 ms in stress runs): a burst of runs leaves thousands of tasks waiting, and their reasons (only shown) are filled in over the following rounds rather than in one long one (B18). The waiting counts in the metrics still cover every task.
Functions§
- attempt_
inputs - The inputs of an open attempt as JSON (what
FetchInputsstreams when they were too big forAssignTask);Nonefor an unknown or ended attempt. Only reads the database, so it needs none of the master’s state, nor its lock: a busy master doesn’t hold a task’s start up (B11). - finished_
ack - The acknowledgement of
attempt_id’sFinished, forworker_id: its result is stored.