Jobs¶
Workers process two job kinds: flake jobs and build jobs. The sections below document the messages, the reports, and failed, aborted and lost jobs.
- The server delivers work as
AssignJob { job_id, assignment_id, job, cluster }messages. - Echo the
assignment_idinJobUpdate,JobCompleted,JobFailed,BuildProgressandEvalProgress. Reports with a staleassignment_idwill be rejected by the server. - Workers accept a re-sent
AssignJobfor a job already in progress. Reports for that job then echo the newassignment_id. - Only cluster members receive a
clusterfield. - Reports of a session go into a queue of 64 events, off the session's read loop. Reports apply in arrival order.
Flake Jobs¶
Flake jobs fetch and evaluate a flake. The server can pick the steps at queue time.
| Situation | Steps |
|---|---|
| An idle evaluation-only worker is available, and the evaluation is no cluster member | [FetchFlake], then a follow-up job [EvaluateFlake, EvaluateDerivations] on the Cached source |
| Otherwise | All three steps in a combined job |
| Field | Meaning |
|---|---|
steps |
FetchFlake, EvaluateFlake, EvaluateDerivations |
source |
Repository { url, commit }, or Cached { store_path } for a follow-up job or a gradient build upload |
wildcards |
Attribute patterns to evaluate |
timeout_secs |
Optional limit, sent as None by the server today |
input_overrides |
Flake input overrides of the task |
input_update |
Set for a flake update |
Fetch¶
- Clone the repository. Skip the clone for a
Cachedsource. - Run the flake update generator for a job with
input_update. - Serialise the tree at the pinned commit as a NAR, without a nix process. Add the NAR to the store as
<narHash>-source, the path ofnix flake prefetchfor the same tree. - Leave out inputs with an override. Overrides apply at evaluation. Override names without a matching input end up as
EvalMessagewarnings. - Pull missing locked inputs from the Gradient cache. Fetch the rest with
builtins.fetchTreein an eval worker.- Inputs of the same second-level domain (such as
github.com) download in sequence. Different domains download in parallel. - Failed inputs drop out with a warning.
- Inputs of the same second-level domain (such as
- Report
FetchResult { flake_source }. -
Upload the source and the inputs with a
Pushcache query. Upload and evaluation steps of the same job run side by side. -
Upload failures fail the whole flake job.
- Fetch-only jobs send
JobCompletedafter the upload, withEvalProgressresent meanwhile. - The server can then queue the follow-up job. Evaluations without a
flake_sourcefail instead.
Evaluate¶
| Step | Worker action |
|---|---|
EvaluateFlake |
Status EvaluatingFlake only, no work |
EvaluateDerivations |
Eval cache pull, attribute discovery, closure walk, eval cache push |
- Eval Cache: Before discovery, workers pull the evaluation cache segments they lack. New rows travel up as segments every 30 s, plus once after a successful evaluation. See Shared Eval Cache.
- Eval Cache Segments: Segments each belong to one cache. Pulls read segments from every readable cache of the project. Pushes write into the first writable cache. Compaction can then copy the result into the other writable caches.
- Attribute Failures: Workers send them as
EvalMessage { level: Error, source: "nix-eval:<attr>" }before the lastEvalResult. - Import From Derivation: Workers send
ImportRequest { drv_paths }during discovery and wait forImportResult. - Missing Inputs: Workers send
InputRequest { request }for an input in neither the store nor the cache, and wait forInputResult. The server can send the download asFetchInputto a worker withnetwork. That worker can push the input under thefetch_idand answer withInputFetched. - Walk: Workers walk an entry point as soon as discovery returned it.
- Waves: Waves hold up to 256 of the most recently found derivations. Leaf derivations then come early in the walk, and their builds can start mid-evaluation.
sequenceDiagram
participant W as Worker
participant S as Server
loop each wave with unvisited dependencies
W->>S: QueryKnownDerivations { drv_paths }
S->>W: KnownDerivations { known }
end
loop every 500 derivations with reported or known inputs
W->>S: CacheQuery { Push } + uploads (.drv files, sources)
W->>S: JobUpdate { EvalResult { derivations } }
end
W->>S: JobUpdate { EvalResult { derivations, warnings } }
W->>S: JobUpdate { EvalStats }
W->>S: JobCompleted
- Derivations in
knownhave complete closures in the graph. Workers skip their subtrees. - Workers treat a failed
QueryKnownDerivationsas an emptyknown. Full rewalks get an emptyknowntoo. - Batches upload their
.drvfiles and input sources before theirEvalResultmessage. Builds can start during the walk. - Input
.drvfiles travel with the batch walking the input. - Walk and batch uploads run side by side. Uploads of consecutive batches overlap.
- Batch uploads come before the
EvalResultmessage for each batch. Batches go out when they reach 500 derivations or 1 MiB during traversal. A derivation can only join a batch, if each input derivation is in that batch, in an earlier batch of the job, or inknown. - Workers query and upload each path no more than once per evaluation, apart from the input upload of the fetch step.
- The server can store each batch in the graph and move each startable build to
Queuedright away. - Consecutive
EvalResultbatches of a job, already waiting in the session queue, reach the graph writer together. Limits of the merge: 5000 derivations, and no other event in between. - Evaluations in
EvaluatingFlakeorEvaluatingDerivationturnBuildingonJobCompleted. EvalResulterrors (no derivation matched, a failed listing) become error messages. Error messages fail the evaluation at the end.
Build Jobs¶
Each build job contains a single BuildSpec and maps to one shared build (a derivation_build).
kind |
Condition | Work performed |
|---|---|---|
Build |
Default | Prefetch the inputs, then build the derivation with the Nix daemon |
Substitute |
Outputs exist in an upstream cache | Fetch the outputs without a Nix store |
Download |
Fixed-output derivation on the builtin system |
Download the file without a Nix store |
SubstituteandDownloadjobs can run on any worker, since these use thebuiltinsystem.- Build jobs also receive
drv_path,outputs,is_fixed_output,timeout_secsandmax_silent_secsfrom the spec. -
Defaults:
build.defaultTimeoutSecs(14400) andbuild.defaultMaxSilentSecs(3600). -
Check for an abort request first. Then report
Building, before anything that can fail. - If all outputs already exist in the local store, skip prefetch and build. Report
BuildOutput { substituted: true }and upload the outputs anyway. - Prefetch: Read the
.drv, drop inputs already present in the store, and fetch the remaining ones over the transfer protocol. - Run the build through the daemon. Stream the log as
LogChunkmessages. - Report
BuildOutputwith the outputs,hydra-build-productsand metrics. - Upload the outputs, then send
JobCompleted. An upload failure marks the job asTransient.
Reports¶
JobUpdate kind |
Effect on the server |
|---|---|
Fetching, EvaluatingFlake, EvaluatingDerivations |
Evaluation status |
FetchResult { flake_source } |
Store the fetched source in evaluation.flake_source |
EvalResult |
Store a batch of derivations in the graph |
EvalStats |
Evaluation metrics |
InputUpdateResult |
Flake update candidate lock and bumped inputs |
InputSources |
Repository and branch of each tracked flake input (protocol 56 and later). These details match a push to the input repository. |
InputUpdateExpansion |
Input names matched by a glob in a discover_only pass. A new evaluation per name |
Building { build_id } |
Build turned Building. Already aborted builds get AbortJob instead |
BuildOutput |
Output sizes, build products, metrics, the substituted flag |
Stage(Prefetch / Build / Upload) |
Live stage of the job in the worker pool, used for the estimated time. Prefetch and Build apply to the Build kind only |
Compressing |
No change. Workers no longer send it |
EvalProgressmessages hold one download row per flake input during fetch, and the live thunk count during evaluation.- Download rows appear only with a missing input. Eval workers download the inputs themselves, with at most 1 download per second-level domain.
JobCompletedandJobFailedhold the phase timeline shown on the Job Board.- Build metrics also hold the number of concurrent builds on the worker, the cores of the build and the worker's CPU score.
Failures¶
BuildFailureKind |
Result |
|---|---|
Transient |
Retried up to build.maxAttempts (3), backoff build.retryBackoffSecs (30 s) doubling. Builds available in a cache take the substitution miss path after the last attempt |
Permanent |
Failed. Builds needing the failed build turn DependencyFailed |
Timeout |
Timed out. Builds needing the timed-out build turn DependencyFailed |
SubstituteUnavailable |
Re-queued. Built normally after build.substituteMissEscalationThreshold (2) misses |
InputsUnavailable |
Self-heal, see below |
CorruptEvalCache |
Purging the evaluation cache segments and re-queuing the evaluation. A repeat within one hour of the purge, or with nothing to purge: evaluation Failed. For builds: Permanent |
Aborted |
Aborted by the server. No cascade |
Canceled |
Stopped by the worker. Re-queued without using an attempt, see Worker Stop |
- InputsUnavailable: An input listed by the cache was missing. Causes are an uncached path,
404/410on the URL,NarUnavailableor a NAR hash mismatch.- The server can delete the outdated cache row and object, reset the producing build and retry.
- Inputs still present but without a producer stay in place.
- Builds fail permanently after
build.inputsUnavailableMaxLoops(3) loops.InputsUnavailablefailures also use up attempts. Attempts and loops both default to 3. Attempts run out first.
- DependencyFailed can spread upward over the dependency graph from
PermanentandTimeoutfailures, across evaluations. - Eval Job Outage: Eval jobs failing
Transientre-queue the evaluation, up tobuild.maxAttempts(3) attempts. Abandoned dispatches stay out of this count.- Typical causes are a dropped server connection, or an object PUT or
CacheQuerywithout an answer.
- Typical causes are a dropped server connection, or an object PUT or
- Out of Memory: Builds killed by the kernel for memory count as
Transient, whatever kind the worker sent. The attempts close with the reasonOom.- Out-of-memory failures only return to
FailedTransientwithout consumingbuild.maxAttemptsif the attempt has a known project andBuildMetrics.build_coresis above 1 and below every earlier kill of that derivation in the same project. Other kills consume one attempt. The next attempt can reduce the core count by one third. - A kill at 1 core can end the build as
FailedPermanentwith the messageran out of memory with 1 core. - Out-of-memory builds from workers without a core count use up attempts like other
Transientfailures.
- Out-of-memory failures only return to
- Builds Larger Than Every Worker: Builds wait for a larger connected worker available to the project when they exceed the total RAM of the worker at the largest core step. They run there at that step. Builds wait for that largest worker when predicted RAM is above the capacity of all workers. They wait for that worker even with 1 core and RAM proportional to the core count. Smaller workers accept neither kind. Such builds can fail only through an out-of-memory kill. Only attempts from releases before 2.1 have reason
NotEnoughResources. - Evaluations end
Completed, orFailedwith a build inFailed,AbortedorDependencyFailed, or with an error message present.
Cluster Members¶
Cluster members reach workers in an AssignJob with cluster = { attempt, role, index, hold_secs }.
| Event | Worker |
|---|---|
AssignJob with cluster |
The worker reserves the slot without running the job, then accepts it. A second member of the same attempt gets rejected |
StartCluster { attempt, roster } |
The worker starts the held member. The roster opens the member's signal route |
ClusterSignal from the server |
The worker delivers the signal to the inbox of the running member of that attempt. After that member finished, the worker drops signals. No executor reads the inbox yet |
ClusterSignal to the server |
The worker forwards signals on the wire only. The server handles routing. No executor sends signals yet. to = None reaches all other started members |
AbortCluster { attempt } |
The worker drops a held member without a report and aborts a running member with JobFailed { Aborted } |
AbortJob for a held member |
The worker releases the slot and reports JobFailed { Aborted } with aborted by server |
No StartCluster within hold_secs |
The worker releases the slot and reports JobFailed { Aborted } with cluster start timed out. The check runs on the 10 s heartbeat, so detection can lag by up to 10 s |
| Worker stop | The worker releases all held members the same way, with worker draining |
- Held members count against
eval.maxConcurrent/build.maxConcurrentlike running jobs. - Held exec members lease a guest address first and accept with
AssignJobResponse.endpointset to that address. Workers reject the member withNo free guest addresses in `exec.subnet.v4`on a full subnet. - Versions 11 and later of the guest protocol include
GuestNetworkIpv6inRunJob.network.ipv6_configuration, with an address, a prefix length and a gateway. Workers fill this field only when worker configs set optionexec.subnet.v6. Agents below protocol 11 receive no IPv6 configuration and use IPv4 only. - Exec job executors get the roster and the lease from the worker on
StartCluster. The executor can build the cluster context from the roster endpoints andJobContext.master_port. - Duplicate roster addresses fail the node with
Two nodes have guest address <address>. Assign a unique exec.subnet.v4 to each exec worker. hold_secs: the server'sscheduler.clusterPrepareTimeoutSecs(30 s) plus a 10 s margin.
Split Evaluation Members¶
A cluster member with the role split-evaluation-primary or split-evaluation-companion can evaluate part of one flake (gradient-worker/src/executor/eval_split.rs).
| Member | Steps |
|---|---|
| Primary | Fetch the flake as usual. Push the inputs during planning, then send EvalSourceReady. Ask with EvalShardRequest { have_source = true }. On Plan: plan the shards, report the plan errors, upload the new eval cache rows, send EvalShardsPlanned. Then take shards |
| Companion | Ask with have_source = false until Source arrives. Fetch that store path from the cache. Then take shards |
| Taker loop | Per shard: pull new eval cache segments, pull drv_paths in one batch, list the shard across the local subprocesses, stream EvalResult batches. The next request can carry finished with the deferred sets |
| End | Finished: send EvalStats, then JobCompleted |
- A
Waitresponse can pause a member forretry_after_ms(1000 ms). A member with a running shard can poll again after the pause. That member can also poll sooner when the shard completes. - Only the primary can report
EvaluatingFlakeandEvaluatingDerivations. - A 30 s flush timer uploads new eval cache rows while shards are running, up to 4 segments at a time. One final upload follows the last shard.
- Message shapes: Split Evaluation Messages.
Abort and Lost Workers¶
- API Abort: The evaluation receive the status
Aborted. Pending jobs of the evaluation leave the queue. AbortJobmessages arrive at the evaluation job. A running build with no other evaluation behind it can also get one.- All evaluations that wanted the build take part in the decision,
CompletedandFailedones included. Dispatching evaluations don't take part. - Newer Evaluation: A task with
hard_abortconcurrency abort the older evaluation of the branch in the same way as an API abort. A task withsoft_abortcancel only its eval job.- A task with
autoconcurrency act likehard_abort. The abort take place after the newer evaluation moved toBuilding.
- A task with
- Unbuildable Evaluation: An evaluation with no worker for its systems also finish
Aborted. - Workers stop the daemon build at once and answer with
JobFailed { Aborted }. - Assignments of an unconfirmed abort close as abandoned after 5 min.
- Reclaim Grace: A disconnected worker keeps its open assignments for
proto.assignmentReclaimGraceSecs(600 s). A grace can't outlast the remainingmaxLifetimeof a worker that disconnected from a running server.- Workers list their running jobs in
RunningJobsafter the reconnect. The server reattaches each listed assignment, and the job continues. - The
unreclaimed-job-sweeppass checks every 10 s on every server instance. A job can outlast the grace by up to 10 s. - Open assignments left by a server restart get the full grace.
- Cluster members, server-dialed sessions and a grace of
0skip the wait. - A worker back after the grace receive
AbortJobfor its listed jobs. That loss can increase the lost-worker streak by one at most.
- Workers list their running jobs in
- Lost Worker: A job without a reclaim within the grace has a lost worker. A job missing from
RunningJobshas one at once. Open assignments close as abandoned.- Each build in
Buildingreturn toQueued. Its running attempt close asAbortedwith the reasonWorkerLost. - A build with 10 lost workers in a row finish
FailedPermanent. An attempt closed in any other way reset the row. A requeue after an ended cluster attempt do not count as a lost worker. - Running evaluations move to
Waitingand back into the queue. - An evaluation with 10 recorded eval dispatches fail on the next lost worker. Dispatches of all outcomes count, fetch-only and canceled jobs included.
- Each build in
Worker Stop¶
sequenceDiagram
participant W as Worker
participant S as Server
Note left of W: SIGTERM
W->>S: JobFailed with Aborted (held cluster members)
W->>S: Draining
Note left of W: aborting all running jobs
W->>S: JobFailed with Canceled
W-xS: close
- Workers first release the cluster members that they hold. They then send
Drainingand abort all running jobs. Exec jobs keep running withstopGuestsWithWorker = falseand resume after a restart. - Canceled jobs report
JobFailed { Canceled }together with the phase timeline. Transient failures during shutdown (a lost nix-daemon connection, for example) also report asCanceled. All other failures keep their kind. - Workers wait up to 5 s for these reports.
- Jobs without a report within the 5 s re-queue with the closed session, as for a lost worker.
- Canceled builds return to
Queued. Their attempts close asAbortedand stay out ofbuild.maxAttemptsand the substitution miss count. - Canceled eval jobs return their evaluation straight to
Queued. - Their assignments close as abandoned. These stay out of
build.maxAttempts, but still count toward the 10 eval dispatches above.