Skip to content

server: serialize Unix socket startup - #2920

Open
NUAAwqy wants to merge 3 commits into
mozilla:mainfrom
NUAAwqy:taiyi/fix-unix-socket-startup-race
Open

NUAAwqy wants to merge 3 commits into
mozilla:mainfrom
NUAAwqy:taiyi/fix-unix-socket-startup-race

Conversation

@NUAAwqy

@NUAAwqy NUAAwqy commented Oct 19, 2026 •

Copy link
Copy Markdown

When multiple clients automatically start sccache with the same private Unix socket, each child currently removes the socket before binding. Concurrent starters can unlink a live listener or race into File exists (os error 17).

This change serializes Unix socket probing, stale-socket cleanup, and bind with a persistent 0600 sibling lock. It reports a live listener as AddrInUse, reclaims only a current-user-owned stale socket, and leaves regular or uncertain paths intact. TCP and abstract Unix sockets are unchanged.

Closes #2906.

Validation on Linux against upstream main at d72ff0bb07ca3be71000e0922a3ef80b21d51403:

  • Added a regression test for preserving a live listener, reclaiming its stale path, and creating a 0600 lock.
  • cargo test --locked --lib --bins --tests: 583 passed, 0 failed, 1 ignored.
  • The issue reproduction with 20 rounds of 4 concurrent clients: 0 failed clients after the fix.
  • cargo clippy --locked --all-targets passes with the repository's existing removed/renamed-lint and async-trait compatibility exceptions; git diff --check passes.
  • The local cargo fmt -- --check reports only the pre-existing start_server closure formatting difference from this checkout's rustfmt; the changed lines are formatted. Release build validation is unavailable here because the server's GCC 9.4 fails the aws-lc-sys compiler safety check.

Prepared with Codex assistance; no human review is claimed.

Follow-up: the repository rustfmt failure was reproduced locally in start_server and fixed by applying rustfmt's closure formatting; cargo fmt -- --check now passes.

Serialize Unix socket probing, stale-socket cleanup, and bind with a
persistent owner-only lock. Preserve live and unsafe socket paths.

Closes mozilla#2906.

Prepared with Codex assistance; no human review is claimed.
@codecov-commenter

codecov-commenter commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.22222% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.14%. Comparing base (d72ff0b) to head (3c2c0f9).

Files with missing lines Patch % Lines
src/server.rs 72.22% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2920      +/-   ##
==========================================
+ Coverage   78.13%   78.14%   +0.01%     
==========================================
  Files          74       74              
  Lines       43570    43628      +58     
==========================================
+ Hits        34043    34093      +50     
- Misses       9527     9535       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

NUAAwqy and others added 2 commits October 20, 2026 14:28
Apply the repository rustfmt output to the existing Unix socket startup fix.

Prepared with Codex assistance; no human review is claimed.

Signed-off-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-Authored-By: Codex <noreply@openai.com>
Prepared with Codex assistance; no human review is claimed.
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.

Concurrent automatic Unix-socket server startup can fail with 'File exists (os error 17)'

3 participants