Skip to main content

Module dispatch

Module dispatch 

Source
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 before AssignTask is sent.
  • Started means accepted. For an attempt that was taken back or ended, the worker is told to kill it.
  • Rejected takes the assignment back (it isn’t a try): a temporary reason queues the task again at once; “code not there yet” after CODE_RETRY_DELAY, and unschedulable once 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 becomes unschedulable when every eligible worker rejected it, until the set of workers changes or a user retries it. A task being cancelled is cancelled instead.
  • 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.
  • Finished is stored (the first one counts) and always acknowledged.
  • An attempt with no Started within the worker lease ends assignment_expired and the task runs again without using a retry; a lost worker’s attempts end lost.

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.
ReadBack
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 interval for up to window, 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§

DispatchError
Why a dispatcher operation failed.
KeptResults
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 its max_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 FetchInputs streams when they were too big for AssignTask); None for 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’s Finished, for worker_id: its result is stored.