Repository navigation
fix: apply a pulled report in the lock order of a disconnect, which disposes its synchronizer - #2071
Conversation
…e action, whatever lock the caller holds LSPDiagnosticsApplier.scheduleRefresh submits a non-blocking read action, whose submit() runs a read action to register the project of withDocumentsCommitted, and so waits while a write action runs. A document that applies a pulled report holds the lock of its diagnostics, which the UI thread takes as the document changes in a write action: the two waited for each other, as PullResultIdTest did on the 2025.3 job of main. From a thread which is neither the UI thread nor in a read action, the refresh is now submitted from another thread of the pool. It is still pending before scheduleRefresh returns.
…isposes its synchronizer A document synchronizer applied a pulled report holding the lock of its diagnostics, and the publication of the diagnostics of a document that isn't open takes the documents lock of the language server. A disconnect holds the documents lock while it disposes the synchronizer, which takes the lock of its diagnostics: the two waited for each other, as WorkspaceDiagnosticsTest did on the 2025.3 job of redhat-developer#2069. The synchronizer now takes the documents lock first, as the disconnect does.
…port-in-the-lock-order-of-a-disconnect
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2071 +/- ##
==========================================
+ Coverage 50.13% 50.16% +0.02%
==========================================
Files 813 813
Lines 33497 33500 +3
Branches 5221 6890 +1669
==========================================
+ Hits 16795 16806 +11
+ Misses 14070 14063 -7
+ Partials 2632 2631 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
Builds on #2065, now merged. Holding the documents lock while the diagnostics are published is safe only once their refresh doesn't wait for a write action, which #2065 makes so.
The
Test (ubuntu-latest, 2025.3)job of #2069 hung inWorkspaceDiagnosticsTest.testCloseFiltersWorkspacePullWithoutPreviousResultId(run), on a deadlock that #2069 doesn't touch:LanguageServerWrapper.disconnectholds the documents lock of the language server (documentsLock) and disposes the synchronizer of the document, whosedispose()waits for the lock of its diagnostics (diagnosticLifetime).diagnosticLifetime, held so that a disposal waits for the publication (fix: stop pull diagnostics after document disposal #1699). The publication of the diagnostics of a document that isn't open, as the one being closed, or a related document of the report, takesdocumentsLock(LanguageServerWrapper.getClosedDocument), and waits for the UI thread.The synchronizer now takes
documentsLockbeforediagnosticLifetimewhen it applies a report, in the order of the disconnect (LanguageServerWrapper.getDocumentsLock). No other code takesdiagnosticLifetimeand thendocumentsLock. The disposal still waits for a publication under way, as before.Test:
PulledReportDisconnectTestholds the documents lock, as a disconnect does, asks for a pull whose report has a related document that isn't open, waits until the thread that applies the report waits for the documents lock, and disposes the synchronizer: without the change, the two wait for each other, as on the runner, and the test hangs; with it, the disposal ends at once. The diagnostics, pull and document tests pass (110 tests), as does the whole suite (1777 tests, 7 skipped).