Skip to content

fix(build-remote): hash slot-lock filename on ENAMETOOLONG#15512

Draft
lovesegfault wants to merge 1 commit into
masterfrom
fix-build-remote-slot-lock-overflow
Draft

fix(build-remote): hash slot-lock filename on ENAMETOOLONG#15512
lovesegfault wants to merge 1 commit into
masterfrom
fix-build-remote-slot-lock-overflow

Conversation

@lovesegfault
Copy link
Copy Markdown
Member

Motivation

openSlotLock constructs its lock filename from the full rendered store URI:

openLockFile(currentLoad / fmt("%s-%d", escapeUri(m.storeUri.render()), slot), true);

When the remote builder URI contains a long path — e.g. the functional tests use ssh://localhost?remote-store=$TEST_ROOT/machineN?system-features=..., and on CI runners with ~60-char tmpdir components the escaped URI alone pushes the filename past NAME_MAXopenLockFile fails with File name too long. This is what breaks build-remote-trustless-should-pass-{2,3} on nixbuild.net.

The upload-lock a few lines down already handles this (e92dd06):

https://github.com/NixOS/nix/blob/f2d4cc70726244f9fdea0ca9e4d3c76c4d635573/src/nix/build-remote/build-remote.cc#L278-L291

Fix

Apply the same fallback to openSlotLock: catch filename_too_long, hash the store URI with MD5, retry. The -<slot> suffix is preserved so different slots for the same machine still get distinct lock files.

openSlotLock constructs the lock filename from the full rendered store
URI. When the remote builder URI contains a long path (e.g. the
functional tests use `ssh://localhost?remote-store=$TEST_ROOT/machineN`,
and on CI runners with ~60-char tmpdir components the escaped URI alone
exceeds NAME_MAX), openLockFile fails with "File name too long".

Apply the same fallback that the upload-lock already has (e92dd06):
catch filename_too_long, hash the store URI with MD5, and retry. The
slot suffix is preserved so different slots for the same machine still
get distinct lock files.
@github-actions github-actions Bot added the new-cli Relating to the "nix" command label Mar 18, 2026
throw;
// Try again hashing the store URL so we have a shorter path
auto h = hashString(HashAlgorithm::MD5, storeUri);
return open(h.to_string(HashFormat::Base64, false));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't work on case-insensitive filesystems. base32 would work better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants