-
-
Notifications
You must be signed in to change notification settings - Fork 389
Avoid race conditions with VFS and VFS versions #2789
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
Conversation
2c023e1
to
6c6d130
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
I'm wondering what we could do to make this easier. Would it be helpful to have the ability to install a callback which gets called whenever the VFS gets modified? |
The |
Sure, but you have to know that, and you have to deal with all of them. You can't just say "please tell me when the VFS changes". So we're failing to provide a usable abstraction! |
Earlier on IRC I suggested we could pass the VFS value along with the notification handlers that cause it to be changed, and this could be extended to the other kinds of state that Alternatively, I don't think it would be too bad of an idea to remove this state on the |
My problem with this is that handlers already run in
I feel like you're just going to end up saying that Okay, one more idea: what if we had a "big lock" on the LSP server state. You could take the big lock if you're going to do something long-running that relies on having a consistent view of the state. The cost would be that it would block anything else from progressing, but that might just be fine. |
c362937
to
10ce844
Compare
We need to take VFS snapshots as soon as we get a change notification. Consider the following interleaving of events: 1. Change Notification A (updates LSP VFS) 2. Restart Shake Session (A changed) initiated 3. Change Notification B (updates LSP VFS) 4. Restart Shake Session (A changed) takes VFS snapshot and possibly performs more computation 5. Restart Shake Session (B changed) In particular, between step 3 and 5, we took a snapshot for a previous build, but this snapshot included changes from a newer VFS state that the build should not have seen. To fix this, we need to take snapshots as soon as a notification handler is called, before forking any threads. This works because LSP calls all handlers in a single threaded fashion and these handlers block message processing. It is essential to this on the LSP handler thread rather than the reactor thread that GHCIDE sets up in order to maintin the property.
10ce844
to
5dc9af3
Compare
ba1bf60
to
0b2821f
Compare
* Avoid race conditions with VFS and VFS version We need to take VFS snapshots as soon as we get a change notification. Consider the following interleaving of events: 1. Change Notification A (updates LSP VFS) 2. Restart Shake Session (A changed) initiated 3. Change Notification B (updates LSP VFS) 4. Restart Shake Session (A changed) takes VFS snapshot and possibly performs more computation 5. Restart Shake Session (B changed) In particular, between step 3 and 5, we took a snapshot for a previous build, but this snapshot included changes from a newer VFS state that the build should not have seen. To fix this, we need to take snapshots as soon as a notification handler is called, before forking any threads. This works because LSP calls all handlers in a single threaded fashion and these handlers block message processing. It is essential to this on the LSP handler thread rather than the reactor thread that GHCIDE sets up in order to maintin the property. * Disable flaky test 'add missing module (non workspace)'
We need to take VFS snapshots as soon as we get a change notification.
Consider the following interleaving of events:
In particular, between step 3 and 5, we took a snapshot for a previous build,
but this snapshot included changes from a newer VFS state that the build should
not have seen.
To fix this, we need to take snapshots as soon as a notification handler is
called, before forking any threads. This works because LSP calls all handlers
in a single threaded fashion and these handlers block message processing. It
is essential to do this on the LSP handler thread rather than the reactor thread
that GHCIDE sets up in order to maintin the property.