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

Synchronize suggestions loading after the reconnect 2 #9142

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

4e6
Copy link
Contributor

@4e6 4e6 commented Feb 22, 2024

Pull Request Description

related #8689, #9072

Fixes a race between the language server SQL updating logic and the engine DeserializeLibrarySuggestionsJobs when the library suggestions may start loading before the database is properly cleaned up after the reconnect.

Important Notes

As a side effect, arguments are showing slightly (~1 second) faster due to the lower contention between the engine jobs.

Before

Peek.2024-02-22.16-06.mp4

After

Peek.2024-02-22.16-01.mp4

Checklist

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

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • 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.

related #8689

Fixes a race between the language server SQL updating logic and the engine `DeserializeLibrarySuggestionsJob`s when the library suggestions may start loading before the database is properly cleaned up after the reconnect.
@4e6 4e6 added the CI: No changelog needed Do not require a changelog entry for this PR. label Feb 22, 2024
@4e6 4e6 self-assigned this Feb 22, 2024

case msg: Api.SuggestionsDatabaseSuggestionsLoadedNotification =>
logger.debug(
"Starting loading suggestions for library [{}].",
msg.libraryName
)
context.become(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change isn't strictly necessary since applyLoadedSuggestions is a Future, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we need to change the state before starting loading the suggestions

@@ -493,6 +493,9 @@ object SearchProtocol {
updates: Seq[SuggestionsDatabaseUpdate]
)

/** A request to clean the suggestions database. */
case object CleanSuggestionsDatabase
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: since it is a request, I'd rather we name it ClearSuggestionsDatabase

"SuggestionsDatabaseSuggestionsLoadedNotification [shouldStartBackgroundProcessing={}].",
state.shouldStartBackgroundProcessing
)
if (state.shouldStartBackgroundProcessing) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this was the main source of the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to properly synchronize the state of background notifications in runtime

case Api.BackgroundJobsStartedNotification() =>
self ! SuggestionLoadingCompleted
context.become(
initialized(
projectName,
graph,
clients,
state.backgroundProcessingStarted()
)
)

@4e6 4e6 added the CI: Ready to merge This PR is eligible for automatic merge label Feb 23, 2024
@mergify mergify bot merged commit 7ff90aa into develop Feb 23, 2024
27 of 29 checks passed
@mergify mergify bot deleted the wip/db/debug-suggestions-sync branch February 23, 2024 11:18
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.

2 participants