Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't await FallbackProjectManager updates #10196

Conversation

DustinCampbell
Copy link
Member

Back in 17.10p1, the FallbackProjectManager would apply changes to the project snapshot manager without scheduling the updates on the dispatcher. This had the potential to create correctness and reliability problems if those changes collided with other updates that were scheduled on the dispatcher.

To address the correctness problem, I made the FallbackProjectManager async and awaited any updates to the project snapshot manager. However, this created re-entrancy problems that resulted in deadlocks with Roslyn. I fixed a couple of those re-entrancy problems in 17.10p2, but hangs have persisted.

A recent Watson dump revealed another yet another re-entrancy issue with background document promotion in the IRazorDynamicFileInfoProvider. The hang occurs when waiting for the FallbackProjectManager to add the file, which causes the project snapshot manager to notify listeners of the update, which causes one of the listener to try and perform the background document promotion again, which causes the hang.

To address this, I've decided to just "fire-and-forget" the updates to the project snapshot manager. The updates will still happen on the dispatcher, but we won't wait for them and shouldn't hang.

Back in 17.10p1, the FallbackProjectManager would apply changes to the
project snapshot manager without scheduling the updates on the
dispatcher. This had the potential to create correctness and reliability
problems if those changes collided with other updates that *were*
scheduled on the dispatcher.

To address the correctness problem, I made the FallbackProjectManager
async and awaited any updates to the project snapshot manager. However,
this created re-entrancy problems that resulted in deadlocks with
Roslyn. I fixed a couple of those re-entrancy problems in 17.10p2, but
hangs have persisted.

A recent Watson dump revealed another yet another re-entrancy issue
with background document promotion in the IRazorDynamicFileInfoProvider.
The hang occurs when waiting for the FallbackProjectManager to add the
file, which causes the project snapshot manager to notify listeners
of the update, which causes one of the listener to try and perform the
background document promotion again, which causes the hang.

To address this, I've decided to just "fire-and-forget" the updates to
the project snapshot manager. The updates will still happen on the
dispatcher, but we won't wait for them and shouldn't hang.
@DustinCampbell DustinCampbell requested a review from a team as a code owner April 1, 2024 21:39
@DustinCampbell DustinCampbell changed the base branch from main to release/dev17.10 April 1, 2024 21:40
Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks scary, but no scarier than the old code I guess :)

@DustinCampbell
Copy link
Member Author

Looks scary, but no scarier than the old code I guess :)

It's a little scary. However, I've convinced myself that the only real problem would be that we might queue up extra updates to the project snapshot manager for the same projects/documents if the fallback versions haven't been added yet. However, in that situation, the project snapshot manager should ignore the duplicate updates. At least, that's my working theory.

@DustinCampbell DustinCampbell merged commit c2c1fb3 into dotnet:release/dev17.10 Apr 2, 2024
12 checks passed
@DustinCampbell DustinCampbell deleted the fix-hang-for-realz-this-time branch April 2, 2024 15:24
@DustinCampbell
Copy link
Member Author

@phil-allen-msft: I just merged this for release/dev17.10.

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.

2 participants