Skip to content

libstore: fix race condition when creating state directories (backport #13368)#13637

Merged
mergify[bot] merged 1 commit into2.29-maintenancefrom
mergify/bp/2.29-maintenance/pr-13368
Jul 31, 2025
Merged

libstore: fix race condition when creating state directories (backport #13368)#13637
mergify[bot] merged 1 commit into2.29-maintenancefrom
mergify/bp/2.29-maintenance/pr-13368

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Jul 30, 2025

Running (parallel?) nix in nix can lead to multiple instances trying to create the state directories and failing on the createSymlink step, because the link already exists.

replaceSymlink is already idempotent, so let's use that.

Resolves #2706

I only see this race appearing in Nixpkgs' CI right now, for example https://github.com/NixOS/nixpkgs/actions/runs/15426171510/job/43413501065. It only happens very infrequently. I tried reproducing locally, by just running nix-build ci -A nixpkgs-vet in a loop, but didn't succeed, so far. I'm running Lix locally, but that shouldn't make a difference, the relevant code is the same. I assume I can't reproduce, because I'd need to start from an empty cache, but I'm not sure.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.


This is an automatic backport of pull request #13368 done by [Mergify](https://mergify.com).

Running parallel nix in nix can lead to multiple instances trying to
create the state directories and failing on the `createSymlink` step,
because the link already exists.

`replaceSymlink` is already idempotent, so let's use that.

Resolves #2706

(cherry picked from commit d64c922)
@mergify mergify bot added the automatic backport This PR is a backport produced by automation (does not trigger backporting) label Jul 30, 2025
@mergify mergify bot requested a review from Ericson2314 as a code owner July 30, 2025 12:56
@mergify mergify bot added the merge-queue label Jul 30, 2025
@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label Jul 30, 2025
mergify bot added a commit that referenced this pull request Jul 30, 2025
mergify bot added a commit that referenced this pull request Jul 30, 2025
mergify bot added a commit that referenced this pull request Jul 30, 2025
mergify bot added a commit that referenced this pull request Jul 30, 2025
mergify bot added a commit that referenced this pull request Jul 30, 2025
mergify bot added a commit that referenced this pull request Jul 30, 2025
@mergify mergify bot merged commit 2968e18 into 2.29-maintenance Jul 31, 2025
27 checks passed
@mergify mergify bot deleted the mergify/bp/2.29-maintenance/pr-13368 branch July 31, 2025 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automatic backport This PR is a backport produced by automation (does not trigger backporting) merge-queue store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant