fix(build): serialize cargo registry cache mount to fix concurrent unpack race #12
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/cargo-registry-cache-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
build-binary-static.yml(and its glibc / windows siblings) fail non-deterministically withfailed to unpack package 'nu-ansi-term v0.50.3' ... failed to open .cargo-ok ... File exists (os error 17)(YTMCP-11, run #42).Root cause is a race on the shared cargo registry cache mount, not stale source. The three
build-binary*workflows run concurrently on one runner, and each mounts--mount=type=cache,target=/usr/local/cargo/registrywith the defaultsharing=shared. Twocargoprocesses extracting the same crate at the same time race on creating the extracted source dir and its.cargo-okmarker, so one fails withFile exists.Fix
Add
sharing=lockedto every registry cache mount across all three Dockerfiles. BuildKit then serializes access to that mount across concurrent builds, so only one cargo extracts at a time. The download cache is still shared (deps fetched once); only the extraction step is mutually excluded, so there is no download-cost regression.While in these files, replaced the force-flagged removals with non-force equivalents per the repo's no-force-flags rule:
rm -rf src->rm -r srcin all three priming steps, andrm -rf /var/lib/apt/lists/*->rm -r /var/lib/apt/lists/*in the glibc runtime stage. Both targets always exist at those points, so removal without-fsucceeds; a failure there now surfaces a real bug instead of being silently ignored.Note for the runner
The corrupt cache left by the original failed run still needs a one-time prune on the runner (e.g.
docker buildx prune --filter type=exec.cachemount). This source change prevents the race from recurring; it does not retroactively clean the already-corrupt mount. The YTMCP-11 triage classified this ashuman_action-only, which is half right: the human prune clears the existing corruption, and this change stops it coming back.#YTMCP-11