Skip to content

hub: dedupe input staging per worker session, not per build - #64

Merged
Mic92 merged 6 commits into
mainfrom
build-fix
Jul 15, 2026
Merged

hub: dedupe input staging per worker session, not per build#64
Mic92 merged 6 commits into
mainfrom
build-fix

Conversation

@Mic92

@Mic92 Mic92 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

AddToStoreNar needs a path's references valid first, but that was only
enforced within one build: the hub topologically ordered a build's own
missing paths, while the worker deduped shared paths across concurrent
builds (owner/awaiter). Two builds could each own one half of a
reference edge and, depending on staging-permit order, the referrer was
imported before its reference, failing the build with
"path ... is not valid".

Move the dedupe to the hub: the worker reports every invalid path, and
the hub skips paths already streamed to this worker session. Staging
phases are serialized on the per-session permit and the worker imports
NARs in stream order, so a skipped path is committed before a later
build's inputs arrive; the worker re-checks skipped paths when its
staging completes. Paths of a failed build are dropped from the session
set so a later build streams them again.

Removes the worker-side SessionImports machinery; docs/staging.als
models the invariant (Alloy 6).

@Mic92
Mic92 enabled auto-merge (rebase) July 15, 2026 11:30
AddToStoreNar needs a path's references valid first, but that was only
enforced within one build: the hub topologically ordered a build's own
missing paths, while the worker deduped shared paths across concurrent
builds (owner/awaiter). Two builds could each own one half of a
reference edge and, depending on staging-permit order, the referrer was
imported before its reference, failing the build with
"path ... is not valid".

Move the dedupe to the hub: the worker reports every invalid path, and
the hub skips paths already streamed to this worker session. Staging
phases are serialized on the per-session permit and the worker imports
NARs in stream order, so a skipped path is committed before a later
build's inputs arrive; the worker re-checks skipped paths when its
staging completes. Paths of a failed build are dropped from the session
set so a later build streams them again.

Removes the worker-side SessionImports machinery; docs/staging.als
models the invariant (Alloy 6).
Mic92 added 3 commits July 15, 2026 13:40
When an output or tmp-dir unpack task fails, the next chunk send only
sees a closed channel and reported a generic "unpacker died", hiding
the actual cause (e.g. no space left on device). Reap the task and
propagate its error, with the store path for output unpacks.
Pull in latest harmonia crates so tribuchet builds against current
store protocol and NAR handling fixes.
Mic92 added 2 commits July 15, 2026 14:55
writeText-style derivations do `mv "$textPath" $out`; on a rootless
Linux worker the .attr file is unpacked by the worker uid, which is
unmapped in the build's user namespace, so the kernel refuses the
unlink (may_delete: HAS_UNMAPPED_ID -> EPERM). Currently fails; the fix
needs the tmp dir to be unpacked with mapped ownership.
The worker unpacks the tmp dir archive as its own uid, which is
unmapped in the build's user namespace, so the kernel refuses to unlink
those files there (may_delete: HAS_UNMAPPED_ID -> EPERM). writeText's
`mv "$textPath" $out` hits this on the passAsFile .attr-* files.

Attach the top tmp dir as a fourth fd to the Allocate call and have
sandboxd chown the tree to the leased base uid before replying. Only
worker-owned inodes are re-owned, so the worker cannot repurpose this
to take over files it can merely open. Disk cleanup now covers the
whole leased-owned top/ tree.
@Mic92
Mic92 merged commit 2fb4795 into main Jul 15, 2026
9 checks passed
@Mic92
Mic92 deleted the build-fix branch July 15, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant