-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
WorkspaceService not Concurrency-Safe #5820
Comments
I "played" around with a naive decorator based API for this, as well as providing a generic operation queue implementation. See the following commit for usage. Not sure what it's worth, I was thinking that decorator based API are usually kind of sweet. |
APIs should not be changed while fixing it. |
There's also a problem in that we're relying on the file watcher to call "updateRoots": when we have two "spliceRoots" calls in a row, the second may use the "_roots" variables before it has been updated. |
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
A simple test case would consist of a plugin that calls "vscode.workspace.updateWorkspaceRoots" twice in a row: you'll end up with only one of the changes in the workspace roots. |
…ts when writing the workspace file This allows calling workspaceService.addRoot() in quick succession Fixes issue eclipse-theia#5820 Contributed by STMicroelectronics Signed-off-by: Samuel HULTGREN <samuel.hultgren@st.com>
…ts when writing the workspace file This allows calling workspaceService.addRoot() in quick succession Fixes issue eclipse-theia#5820 Contributed by STMicroelectronics Signed-off-by: Samuel HULTGREN <samuel.hultgren@st.com>
@akosyakov have you thought about this issue more? I made a PR which triggers an WorkspaceService.updateRoots() when the workspace file is written. #8605. If we merge both our PRs the code will behave properly for both: for (let path of paths) {
await workspaceService.addRoot(path); // Fixed by my PR
} and for (let path of paths) {
workspaceService.addRoot(path); // Fixed by your PR https://github.com/eclipse-theia/theia/pull/5828
} |
We should use Monaco model, it is thread safe already. As we did it for other settings. |
When invoking WorkspaceService.spliceRoots() multiple times concurrently (for example via the vs code api workspace.updateWorkspaceRoots(), there can be cases where we run into a "out of sync" condition on the workspace file. Splice roots will do something like:
it can happen that the both invocations read the file before any invocation writes the file. When the second invocation then tries to write the file, the "out of sync" check fails and we get a dialog asking whether to overwrite the file.
There is also a discussion on Spectrum: https://spectrum.chat/theia/dev/mutual-exclusion-in-api-calls~9bd83415-ffda-4eb2-8b58-3d35427c701e
The text was updated successfully, but these errors were encountered: