Skip to content

Replace GetInstalled with result.LockFile.Libraries - #7216

Merged
nkolev92 merged 6 commits into
devfrom
dev-nkolev92-10935
Mar 18, 2026
Merged

nkolev92 merged 6 commits into
devfrom
dev-nkolev92-10935

Conversation

@nkolev92

@nkolev92 nkolev92 commented Mar 16, 2026 •

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#10935

Description

Sometimes, when there's many resolvers trying to download the same there'll be a race condition.

Effectively, 2 restores will be set-up and configured early, but one will complete with the full restore before the other gets to the resolver itself.
This is extremely uncommon, even if you configure lots of concurrent restores, most of the time, the restores will end up even reusing the same tasks (cause we sync the http requests).

In here, I'm changing it to an approach to determine that a package has been successfully installed in a different way.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests - Unfortunately no. The race condition is so minute that I could not figure out to force them to end up in the race condition without changing product code. I did write a test that actually validate my fix, but unfortunately that required a change in the queueing code for the restores, which is just unacceptable in general. Maybe someone can be more creative than me, but I had no luck. Copilot spent ~1h on a devbox coming up inadequate ways too, so it wasn't for lack of trying. If you want to inspect that "force failure" test, here's my revert in this branch: 5ac7c7c
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@nkolev92
nkolev92 force-pushed the dev-nkolev92-10935 branch from 5ac7c7c to f9289be Compare March 16, 2026 17:56
@nkolev92
nkolev92 marked this pull request as ready for review March 16, 2026 17:56
@nkolev92
nkolev92 requested a review from a team as a code owner March 16, 2026 17:56

@donnie-msft donnie-msft left a comment

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.

My understanding of the change is that it's unlikely to encounter a race condition while pulling from the assets file, but we know it is (rarely) possible when querying the RestoreGraph in memory?

Co-authored-by: Donnie Goodson <[email protected]>
@nkolev92

Copy link
Copy Markdown
Member Author

My understanding of the change is that it's unlikely to encounter a race condition while pulling from the assets file, but we know it is (rarely) possible when querying the RestoreGraph in memory?

For the purposes of this PR, "installs package" really means, adds the package to the global packages folder.

There's no race condition in the assets file.
Whether a restore installs the package or not, the assets file is still the same.

GetAllInstalled on the other hand, explicitly handles the scenario where the current operation installed the package

/// <returns>A set of libraries that were installed by this operation</returns>

@nkolev92
nkolev92 requested a review from donnie-msft March 16, 2026 18:45
donnie-msft
donnie-msft previously approved these changes Mar 16, 2026
jeffkl
jeffkl previously approved these changes Mar 16, 2026
@nkolev92
nkolev92 dismissed stale reviews from jeffkl and donnie-msft via 73e3931 March 16, 2026 19:39
@nkolev92
nkolev92 requested review from donnie-msft and jeffkl March 17, 2026 20:55
@nkolev92
nkolev92 enabled auto-merge (squash) March 17, 2026 20:56
@nkolev92
nkolev92 merged commit 15db684 into dev Mar 18, 2026
16 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-10935 branch March 18, 2026 00:23
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.

Random error: Failed to resolve SDK 'package/version'. Package restore was successful but a package with the ID of "package" was not installed.

3 participants