Repository navigation
fix: stop a language server without waiting for a write action of the UI thread - #2069
Merged
lagergren merged 1 commit intoNov 21, 2026
Conversation
… UI thread stop() holds the monitor of the language server and disposes the supports of its files in a non-blocking read action, whose expireWith(project) registered on the project in a read action taken at submission: from a thread of the pool, the stop waited for a write action of the UI thread with the monitor held. The read action now expires with expireWhen(project::isDisposed), as EditorFeatureManager.refreshEditorFeature does since redhat-developer#1853.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2069 +/- ##
==========================================
+ Coverage 49.91% 50.17% +0.26%
==========================================
Files 813 813
Lines 33396 33483 +87
Branches 6872 6888 +16
==========================================
+ Hits 16668 16799 +131
+ Misses 14138 14055 -83
- Partials 2590 2629 +39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 21, 2026
Merged
Collaborator
Author
|
@coderabbitai review |
Action not completed
|
Collaborator
Author
|
@coderabbitai review |
Action performed
|
lagergren
added a commit
that referenced
this pull request
Nov 21, 2026
…isposes its synchronizer (#2071) 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 in `WorkspaceDiagnosticsTest.testCloseFiltersWorkspacePullWithoutPreviousResultId` ([run](https://github.com/redhat-developer/lsp4ij/actions/runs/44898419103/job/136828939030)), on a deadlock that #2069 doesn't touch: - The UI thread closes the file: `LanguageServerWrapper.disconnect` holds the documents lock of the language server (`documentsLock`) and disposes the synchronizer of the document, whose `dispose()` waits for the lock of its diagnostics (`diagnosticLifetime`). - A thread of the pool applies a pulled report holding `diagnosticLifetime`, held so that a disposal waits for the publication (#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, takes `documentsLock` (`LanguageServerWrapper.getClosedDocument`), and waits for the UI thread. The synchronizer now takes `documentsLock` before `diagnosticLifetime` when it applies a report, in the order of the disconnect (`LanguageServerWrapper.getDocumentsLock`). No other code takes `diagnosticLifetime` and then `documentsLock`. The disposal still waits for a publication under way, as before. Test: `PulledReportDisconnectTest` holds 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
LanguageServerWrapper.stop()holds the monitor of the language server, and disposes the supports of the files of the stopped language server in a non-blocking read action (disposeFileSupports). Its comment says it must not wait for a read action, but itsexpireWith(project)registers on the project in a read action thatsubmit()runs at once (NonBlockingReadActionImpl.Submission), which waits while a write action runs. So a stop from a thread of the pool, as an idle stop or a restart, waited with the monitor held for a write action of the UI thread, which can need that monitor in the write action: the same kind of deadlock as #2065.The read action now expires with
expireWhen(project::isDisposed), asEditorFeatureManager.refreshEditorFeaturedoes since #1853 for the same reason, which registers nothing at submission.This is what is left of that kind of deadlock after #2065. Of the 17 non-blocking read actions that register on a disposable at submission (
expireWith,withDocumentsCommitted,inSmartMode), the others are submitted on the UI thread or in a read action, where the read action ofsubmit()doesn't wait, or hold no lock while they wait.Test:
StopWithoutWaitingForAWriteActionTeststops a language server with a connected file from a thread of the pool while the UI thread holds a write action, and waits for 10 seconds at most: without the change, the stop waits for the write action, and the test fails. It and the other stop tests pass (24 tests), as does the whole suite (1794 tests, 7 skipped).