You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deadlock came up during testing, appears to be an issue in index.hpp. We're using the Rust bindings for v2.8.16 so through index_dense.hpp. This testing involved deleting a bunch of vectors and then, with multiple threads, calling add(), which then called update() on the deleted nodes.
In update we acquire the lock on the deleted node here. We then call connect_node_across_levels_ which invokes search_for_one_ and search_to_insert_, while locking and locking (respectively) every candidate node it looks at.
This update lock on the deleted node seems to be the problem. If another thread performing an update selects that deleted node as a "next" candidate, we have to wait until the other thread is completely done updating, as we don't drop the update lock until the end of the call. What we've seen somewhat consistently (with 16 threads updating) is a deadlock, where each of the threads needs the candidate lock that another thread updating already holds, and that thread in turn needs the candidate lock a different thread holds.
Replicated it, will make part of the primary testing suite in C++. Thanks for finding and reporting the issue, @chun0nick! Would you be open to be mentioned as a contributor for this patch? 🤗
I had what looked to be a deadlock happen when using the Python api (as part of usearch_molecules indexing step) when using 32 threads. Could this bug be the cause of that?
Yes, @sef43, the issue is coming from the core in update-heavy workloads. Haven't finished patching yet, was busy the last few days with new bindings for UForm and new algos in StringZilla.
Hi, was curious if there was movement on this issue - I've taken a few cracks at a fix but have quickly found myself touching quite a bit of code that I wasn't super confident with. Thanks!
I've spent some time on this recently as well. Concurrent updates are quite tricky, especially if you want to avoid inefficient memory usage. I found no clean way of keeping a 2-layer solution, separating the logic between index_gt and index_dense_gt.
A better solution might be to have a more advanced compare-exchange-like operation in index_gt.
After my weekend patches, every other core C++ test on the main-dev branch passes, except for these concurrent updates and weird SEGFAULT in Python bindings, so its a core priority 🤗
@ashvardanian it's been a while, I wonder if it fell out of your radar, were you able to get this fixed? Is there any branch that contains partial fixes?
Hi @vitarb! I would heavily discourage concurrent removals and updates in the current v2. I'd love to learn more about your usecase and if you'd like to be participating in the v3 preview. We can continue over email as well - [email protected] 🤗
@chun0nick, thanks for the report, and @sef43 and @vitarb for following up! 3.0 drops the v2 update() along with its locking, and removal returns in #846 as an exclusive call that never races with inserts or searches, so replacing an entry becomes a removal followed by an insert. I'm closing this in its favor.
Activity
ashvardanian commentedon Apr 12, 2024
Good catch! Looking into it! Feel free to submit a test-case or patches via PR while I do 🤗
ashvardanian commentedon Apr 15, 2024
Replicated it, will make part of the primary testing suite in C++. Thanks for finding and reporting the issue, @chun0nick! Would you be open to be mentioned as a contributor for this patch? 🤗
chun0nick commentedon Apr 15, 2024
Awesomely fast response! And sorry - was planning to give you a test case today. Sure, would be happy to be mentioned as a contributor.
sef43 commentedon Apr 23, 2024
I had what looked to be a deadlock happen when using the Python api (as part of usearch_molecules indexing step) when using 32 threads. Could this bug be the cause of that?
ashvardanian commentedon Apr 23, 2024
Yes, @sef43, the issue is coming from the core in update-heavy workloads. Haven't finished patching yet, was busy the last few days with new bindings for UForm and new algos in StringZilla.
chun0nick commentedon Jul 8, 2024
Hi, was curious if there was movement on this issue - I've taken a few cracks at a fix but have quickly found myself touching quite a bit of code that I wasn't super confident with. Thanks!
ashvardanian commentedon Jul 8, 2024
I've spent some time on this recently as well. Concurrent updates are quite tricky, especially if you want to avoid inefficient memory usage. I found no clean way of keeping a 2-layer solution, separating the logic between index_gt and index_dense_gt.
A better solution might be to have a more advanced compare-exchange-like operation in index_gt.
After my weekend patches, every other core C++ test on the main-dev branch passes, except for these concurrent updates and weird SEGFAULT in Python bindings, so its a core priority 🤗
vitarb commentedon Feb 13, 2025
@ashvardanian it's been a while, I wonder if it fell out of your radar, were you able to get this fixed? Is there any branch that contains partial fixes?
ashvardanian commentedon Feb 14, 2025
Hi @vitarb! I would heavily discourage concurrent removals and updates in the current v2. I'd love to learn more about your usecase and if you'd like to be participating in the v3 preview. We can continue over email as well - [email protected] 🤗
ashvardanian commentedon Nov 14, 2026
@chun0nick, thanks for the report, and @sef43 and @vitarb for following up! 3.0 drops the v2
update()along with its locking, and removal returns in #846 as an exclusive call that never races with inserts or searches, so replacing an entry becomes a removal followed by an insert. I'm closing this in its favor.