Skip to content
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

Progress messages logic might have race conditions #1749

Closed
ndmitchell opened this issue Apr 18, 2021 · 1 comment · Fixed by #1784
Closed

Progress messages logic might have race conditions #1749

ndmitchell opened this issue Apr 18, 2021 · 1 comment · Fixed by #1784
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@ndmitchell
Copy link
Collaborator

I'm not familiar with the current progress code, so the below is somewhat guesswork and assumption - happy to understand why I'm wrong. There seem to be two invariants around progress messages:

  1. During testing we expect progress messages to be sent. If we don't, the benchmarking fails.
  2. The LSP spec requires that no progress messages be sent between initialise request/response, as per https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#initialize

As far as I can tell, the way we ensure invariant 1 is by forking a progress thread and not doing a sleep at the beginning. Unfortunately, if you make the operations fast enough or lose a bunch of races, it doesn't get a progress notification, and we get failures. I'm seeing a failure with the ghcide benchmarking stuff I think comes from this.

As far as I can tell, the way we ensure invariant 2 is by hoping the initialise gets handled super quickly, and that the timer gets killed. Again, that's using sleeps and races to ensure the property.

I've changed a lot of timing properties around the Shake graph, and am suddenly getting a lot of errors from progress stuff. While these might be due to my changes, my debugging suggests progress itself might be at fault.

@ndmitchell ndmitchell changed the title progress messages logic isn't very robust Progress messages logic isn't very robust Apr 18, 2021
@ndmitchell ndmitchell changed the title Progress messages logic isn't very robust Progress messages logic might have race conditions Apr 18, 2021
@pepeiborra
Copy link
Collaborator

Invariant 1 is indeed an assumption for many tests. It would make sense to have an entirely separate codepath for testing that doesn't spawn a separate thread and instead sends progress notifications directly. Let me look into that.

The proper way to enforce invariant 2 would be to make the request handler synchronous. We already handle notifications synchronously, for instance. I'll look into that too.

@Ailrun Ailrun added the type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. label Apr 18, 2021
@mergify mergify bot closed this as completed in #1784 May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants