Repository navigation
fix: add cross-process file lock to prevent usearch race condition (#543) - #556
Merged
Merged
Conversation
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (1)
Review powered by cora-cli · BYOK · MIT |
) When multiple uteke remember commands run concurrently (e.g. xargs -P5), each process loads the usearch vector index, inserts its vector, and saves — but each save OVERWRITES the other process's inserts, causing data loss. The error 'rename temp to final key mapping: No such file or directory' appears. The existing RwLock<VectorIndex> only protects concurrent threads within a single process. Cross-process coordination requires file-based locking. - Add fs2 dependency for advisory file locking - VectorIndex acquires exclusive file lock on .usearch file during load_or_create(), held until drop - Concurrent CLI invocations block at lock acquisition instead of corrupting the index - 288 tests pass, clippy/fmt clean
ajianaz
force-pushed
the
fix/543-usearch-race-condition
branch
from
July 4, 2026 03:59
33c375c to
4c9761f
Compare
| /// | ||
| /// Acquires an **exclusive file lock** on the `.usearch` file to prevent | ||
| /// cross-process race conditions (e.g., `xargs -P5 uteke remember`). | ||
| /// The lock is held until this `VectorIndex` is dropped (#543). |
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
fix: add cross-process file lock to prevent usearch race condition (#543)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Multiple concurrent
uteke rememberinvocations (e.g.xargs -P5) each load the usearch vector index, insert, and save — each save overwrites other inserts, causing data loss.The
RwLock<VectorIndex>only protects within a single process.Fix
fs2dependency for advisory file lockingVectorIndexacquires exclusive file lock on.usearchfile duringload_or_create(), held untilDropCloses #543