-
Notifications
You must be signed in to change notification settings - Fork 327
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
Conversation
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.
|
||
case msg: Api.SuggestionsDatabaseSuggestionsLoadedNotification => | ||
logger.debug( | ||
"Starting loading suggestions for library [{}].", | ||
msg.libraryName | ||
) | ||
context.become( |
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.
This change isn't strictly necessary since applyLoadedSuggestions
is a Future
, right?
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.
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 |
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.
nit: since it is a request, I'd rather we name it ClearSuggestionsDatabase
"SuggestionsDatabaseSuggestionsLoadedNotification [shouldStartBackgroundProcessing={}].", | ||
state.shouldStartBackgroundProcessing | ||
) | ||
if (state.shouldStartBackgroundProcessing) { |
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.
So this was the main source of the problem?
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.
I had to properly synchronize the state of background notifications in runtime
enso/engine/language-server/src/main/scala/org/enso/languageserver/search/SuggestionsHandler.scala
Lines 317 to 326 in 35fdcd2
case Api.BackgroundJobsStartedNotification() => | |
self ! SuggestionLoadingCompleted | |
context.become( | |
initialized( | |
projectName, | |
graph, | |
clients, | |
state.backgroundProcessingStarted() | |
) | |
) |
Pull Request Description
related #8689, #9072
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.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:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.