microsoft / kernel-memory

RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.
https://microsoft.github.io/kernel-memory
MIT License
1.62k stars 313 forks source link

Bugfix SQLServerMemory semaphore not released properly #883

Closed snakex64 closed 2 weeks ago

snakex64 commented 2 weeks ago

Motivation and Context (Why the change? What's the scenario?)

A simple bugfix for SQLServerMemory. The semaphore wasn't released when "is ready" changes from "false" to "true" while the code was waiting for the semaphore. Meaning if specifically 3 or more tasks run into that code at the same time, the third task as well as all others are gonna be stuck in a deadlock waiting for the semaphore. This only happens during the first initialization, since subsequent calls will leave before waiting for the semaphore.

marcominerva commented 2 weeks ago

@snakex64 @dluc Surely I'm missing something, but I'm wondering how this change (an if instrctuion moved inside a try... catch block):

image

Will modify the behavior?

dluc commented 2 weeks ago

@snakex64 @dluc Surely I'm missing something, but I'm wondering how this change (an if instrctuion moved inside a try... catch block):

image

Will modify the behavior?

it's about the code executed in finally

marcominerva commented 2 weeks ago

Oh... I see, in this way the return causes the semaphore to be released. Thank you for the clarification!