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

Fix a race condition in IDE diagnostic service for stale diagnostics #60365

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

mavasani
Copy link
Contributor

Fixes AB#1487574

If you edit a document, which either fixes or introduces compiler diagnostics in another open document, but you do a tab switch to that open document before diagnostic computation kicked off by prior edit finishes, than we end up cancelling existing tasks queued for diagnostic computation from that prior edit. We kick off new tasks for diagnostic computation for the new active document, but the newly active document did not have any code change, so has identical text and semantic version and we end up skipping diagnostics computation for it, leaving behind stale diagnostics OR not showing new diagnostics that were introduced from the edit in prior active document.

Fix is to always recompute the active document diagnostics on switching active documents and avoid any possible race conditions

Before fix - stale diagnostics

RaceCondition_BeforeFix

After fix - up-to-date diagnostics

RaceCondition_WithFix

Fixes [AB#1487574](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1487574/)

If you edit a document, which either fixes or introduces compiler diagnostics in another open document, but you do a tab switch to that open document before diagnostic computation kicked off by prior edit finishes, than we end up cancelling existing tasks queued for diagnostic computation from that prior edit. We kick off new tasks for diagnostic computation for the new active document, but the newly active document did not have any code change, so has identical text and semantic version and we end up skipping diagnostics computation for it, leaving behind stale diagnostics OR not showing new diagnostics that were introduced from the edit in prior active document.

Fix is to always recompute the active document diagnostics on switching active documents and avoid any possible race conditions
@mavasani mavasani added this to the 17.2.P2 milestone Mar 24, 2022
@mavasani mavasani requested a review from a team as a code owner March 24, 2022 17:14
@mavasani mavasani disabled auto-merge March 25, 2022 08:27
@mavasani
Copy link
Contributor Author

@dotnet/roslyn-infrastructure Can someone please help force merge this? Integration test failures seem to be unrelated known failures. Thanks!

@mavasani
Copy link
Contributor Author

Ping @dotnet/roslyn-infrastructure for help in force merge

@mavasani mavasani enabled auto-merge March 28, 2022 03:09
@mavasani mavasani merged commit 9704fe2 into dotnet:main Mar 28, 2022
@ghost ghost modified the milestones: 17.2.P2, Next Mar 28, 2022
@mavasani mavasani deleted the FixRaceDiagCompute branch March 28, 2022 11:43
@allisonchou allisonchou modified the milestones: Next, 17.2.P3 Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants