Skip to content

Fix race in static graph restore when waiting for callbacks to complete - #7823

Merged
jeffkl merged 3 commits into
devfrom
dev-jeffkl-fix-static-graph-restore-callback-race
Nov 11, 2026
Merged

jeffkl merged 3 commits into
devfrom
dev-jeffkl-fix-static-graph-restore-callback-race

Conversation

@jeffkl

@jeffkl jeffkl commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#15119

Description

The MSBuild APIs allow you to queue builds and specify a callback. After the builds are queued, calling EndBuild() blocks the current thread until all queued builds are complete. However, it does not wait for the callbacks to complete. This means that intermittently, the code will continue after builds are done but a callback is not.

The fix is to use counter of pending callbacks and a ManualResetEvent which signals when the pending build count is at zero.

Coplot also suggested aggregating the exceptions for good measure so that's included as well.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@jeffkl jeffkl self-assigned this Oct 26, 2026
@jeffkl
jeffkl requested a review from a team as a code owner October 26, 2026 18:11
Queue build submissions with project data and process
results synchronously after `BuildManager.EndBuild()`.
Remove asynchronous callback synchronization and exception
handling while preserving build failure and total counts.
@jeffkl
jeffkl requested a review from zivkan November 3, 2026 16:17
Nigusu-Allehu
Nigusu-Allehu previously approved these changes Nov 3, 2026
jebriede
jebriede previously approved these changes Nov 3, 2026
zivkan
zivkan previously approved these changes Nov 3, 2026
Use a normal dictionary with a read-only return contract now that project population is single-threaded. Restore the EndBuild comment and remove obsolete callback coordination from the finalization test.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 86393a61-18b4-453c-b4a8-9439a2327d9c
@jeffkl
jeffkl dismissed stale reviews from zivkan, jebriede, and Nigusu-Allehu via 21185bc November 6, 2026 21:39
@jeffkl
jeffkl requested a review from zivkan November 6, 2026 21:40
@jeffkl
jeffkl merged commit daea459 into dev Nov 11, 2026
18 checks passed
@jeffkl
jeffkl deleted the dev-jeffkl-fix-static-graph-restore-callback-race branch November 11, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants