Skip to content

🔧 [P2] Fix vector index consistency and error handling #139

Closed

Description

@ajianaz

Problem

Multiple issues in crates/uteke-core/src/memory/vector.rs:

1. Sidecar file consistency risk

UUID↔u64 key mapping stored in separate .keys file next to .usearch file. If either is corrupted or they get out of sync (crash between saves), data is lost. No atomic save (write-to-temp-then-rename), no checksum.

2. Sparse Vec growth

key_to_id uses Vec<String> as sparse mapping from u64 to UUID. After deletions, this Vec can hold many empty strings. With 100K inserts and 50K deletes → 100K entries, 50K empty.

3. Silent error swallowing

Failed usearch::Index::add() and remove() log errors but don't propagate. Caller thinks operation succeeded. VectorIndex::insert() returns () not Result.

4. \_ef parameter ignored

The ef (exploration factor) parameter in search() is accepted but ignored. HNSW search quality tuning is impossible.

5. Mutex blocks concurrent embedding

embed() takes &mut self unnecessarily — ONNX session is Send + Sync after init. Forces Mutex on all callers, serializing concurrent operations.

Proposed Fixes

  1. Atomic save: write to temp file, then rename (POSIX atomic on same filesystem)
  2. Replace Vec<String> with HashMap<u64, String> for sparse mapping
  3. Make insert() and remove() return Result<>
  4. Wire _ef parameter to usearch search config
  5. Change embed(&mut self) to embed(&self)

Acceptance Criteria

  • Atomic save for both usearch index and keys file
  • Sparse mapping uses HashMap (or compaction logic)
  • Insert/remove errors propagated to callers
  • ef parameter affects HNSW search quality
  • embed() uses &self instead of &mut self
  • Tests: concurrent insert/remove, crash recovery

Effort: ~1-2 days

Activity

  1. added
    priority:high
    bug
    next-up
    and removed on Jun 9, 2026
  2. added 2 commits that reference this issue on Jun 10, 2026
  3. 2 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnext-uppriority:highscope:core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions