Avoid deadlock on solution close with linked files #17845
Merged
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.
Fixes #17305
Fixes https://devdiv.visualstudio.com/0bdbc590-a062-4c3f-b0f6-9383f67865ee/_workitems?id=388328&_a=edit
Ask Mode Template
Customer scenario I'm not exactly sure how to reproduce it, but multiple reports point to the same problem. When closing a solution, we close a linked file, which causes the running document table to tell us about a context change, which deadlocks. I believe it can hang before saving the solution.
Bugs this fixes:
#17305
https://devdiv.visualstudio.com/0bdbc590-a062-4c3f-b0f6-9383f67865ee/_workitems?id=388328&_a=edit
Workarounds, if any: Close all open documents before closing the solution.
Risk: Fairly low. We avoid taking a lock when the lock has already been taken for us.
Performance impact: Essentially none. No allocations or complexity changes.
Is this a regression from a previous update?: Unknown, but probably. I can't repro it, but the reports seem to be on RC4+ builds.
Root cause analysis: I don't know what regressed it. This should have been fixed in #16889, but I missed the linked files case. Shared Projects and linked files are now both handled appropriately.
How did we miss it? I didn't think there were any additional callers of a particular overload of OnDocumentContextUpdated.
How was the bug found? Customer reports and dogfooding.