Repository navigation
[repo-assist] Fix intermittent git dependency restore failures via cross-process locking - #4407
Merged
dsyme merged 1 commit intoAug 30, 2026
Conversation
…cking Wrap fetchCache calls on the shared git repo cache folder with RunInLockedAccessMode, the existing cross-process locking primitive (paket.processlock) already used elsewhere (e.g. RestoreProcess.fs, PublicAPI.fs). This prevents concurrent 'git remote set-url origin' races when multiple projects/processes restore in parallel against the same shared cache folder. Closes #4266 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme
marked this pull request as ready for review
August 30, 2026 13:03
17 tasks
This was referenced Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist, an AI assistant.
Closes #4266
Root cause
getSHA1OfBranchanddownloadRemoteFilesinRemoteDownload.fscallPaket.Git.Handling.fetchCache, which runs rawgit remote set-url origin .../git remote update --prunedirectly against the shared git repo cache folder (Constants.GitRepoCacheFolder) with no cross-process synchronization.When a multi-project solution with git dependencies is restored — e.g. via
dotnet restoreinvoking Paket per-project, or on a fresh CI checkout where the cache folder doesn't yet exist — multiple processes/tasks can callfetchCacheon the same cache folder concurrently. The concurrentgit remote set-url/fetch operations race and fail with:Fix
Wrap the
fetchCachecalls (in bothgetSHA1OfBranch's version-requirement resolution path anddownloadRemoteFiles's actual checkout path) withRunInLockedAccessMode, Paket's existing cross-process locking primitive (Common/Utils.fs), which uses apaket.processlockfile to serialize access to a folder across processes. This mechanism is already used for similar shared-resource protection elsewhere (RestoreProcess.fs,PublicAPI.fs).This serializes git cache mutation per cache folder across concurrent Paket processes, eliminating the race, while leaving normal (non-conflicting) restores unaffected.
Trade-offs
checkoutToPaketFolder) remains unlocked since each project's checkout folder is distinct.Test Status
dotnet build src/Paket.Core/Paket.Core.fsproj -c Releasesucceeds for bothnet461andnetstandard2.0targets, no new warnings introduced.RunInLockedAccessModeis a well-established, already-used primitive in this codebase for exactly this class of shared-folder-access problem (e.g. issue Could not acquire lock to ...\paket.locked #3535's antivirus/lock-file history confirms its intended purpose).Add this agentic workflow to your repo
To install this agentic workflow, run