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

Ensure slow shutdown of LS always kicks off hooks #6665

Merged
merged 1 commit into from
May 15, 2023

Conversation

hubertp
Copy link
Collaborator

@hubertp hubertp commented May 12, 2023

Pull Request Description

This change fixes the rather elusive bug where shutdown hooks could not be fired when shutdown was taking too long and termination was forced.

Under the circumstances described in detail in ticket #6515 there was a small chance that we could have a shutdown race condition. Essentially the messages received when client was disconnected and language server forced the termination could lead to language server not sending the public ProjectClosed message which triggers shutdown hook. Now we always do.

Also made sure that multiple ProjectClosed messages don't lead to firing multiple shutdown hooks, which was another possibility.

No tests as one would have to be able to introduce different delays in various message handlers to simulate the problem.
Having ability to do such chaos testing would be nice but it is beyond the scope of this ticket.
I was able to reproduce the problem 100% with my specially crafted setup so I'm fairly confident about the change.

Closes #6515.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

This change fixes the rather elusive bug where shutdown hooks could not
be fired when shutdown was taking too long and termination was forced.

Under the circumstances described in detail in ticket #6515 there was a
small chance that we could have a shutdown race condition. Essentially
the messages received when client was disconnected and language server
forced the termination could lead to language server not sending the
public `ProjectClosed` message which triggers shutdown hook. Now we
always do.

Also made sure that multiple `ProjectClosed` messages don't lead to
firing multiple shutdown hooks, which was another possibility.
)
liveControllers.foreach { case (actorRef, projectId) =>
actorRef ! PoisonPill
context.system.eventStream.publish(ProjectClosed(projectId))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one was to reduce this fix to a single line, then this is it.

@hubertp hubertp added the CI: No changelog needed Do not require a changelog entry for this PR. label May 15, 2023
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my high level Akka perspective the change makes sense and your conclusions seem valid.

@hubertp hubertp added the CI: Ready to merge This PR is eligible for automatic merge label May 15, 2023
@mergify mergify bot merged commit 06624f3 into develop May 15, 2023
@mergify mergify bot deleted the wip/hubert/6515-shutdown-race-condition branch May 15, 2023 12:15
Procrat added a commit that referenced this pull request May 16, 2023
…z-6260

* develop:
  Add verbose logs mention to CONTRIBUTING.md (#6703)
  Hide "shared with" column on local backend (#6684)
  Fix top bar styles (#6695)
  Fix opening cloud projects (#6683)
  Show spinner when opening/creating a project (#6321)
  Fix logic for enabling dashboard (#6696)
  Create unique atom getter suggestions (#6694)
  Ensure slow shutdown of LS always kicks off hooks (#6665)
  Fix `--startup.project` to bypass opening dashboard (#6671)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project folder renaming stopped working
3 participants