Skip to content

fix(#442): server deadlock on remember + cosine auto-linking never fires - #443

Merged
ajianaz merged 1 commit into
developfrom
fix/442-server-deadlock-auto-link
Jun 22, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/442-server-deadlock-auto-link

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Critical Fix for #442

Root Cause: RwLock Deadlock

remember_precomputed() holds an RwLockWriteGuard on the vector index (variable index). It then calls auto_link_cosine(), which tries to acquire self.index.read() — a read lock on the same RwLock while the write lock is still held.

This deadlocks the thread permanently. After 2-3 remember() calls, the server Mutex<Uteke> is held by the deadlocked thread, making the entire server unresponsive (even GET /health hangs).

Fix

Add drop(index) before calling auto_link_cosine(). The index entry has already been inserted and saved, so the write lock is no longer needed.

Also Fixes: No Edges Created

auto_link_cosine() was never reaching the search/edge-creation code because it deadlocked on the first self.index.read() attempt. With the deadlock fixed, similar_to and possible_duplicate edges will now be created correctly.

Test

  • 300 unit tests pass
  • Clippy clean, fmt clean

Root cause: RwLock deadlock in remember_precomputed().

remember_precomputed() holds an RwLockWriteGuard on the vector index
(variable `index`). It then calls auto_link_cosine(), which tries to
acquire self.index.read() — a read lock on the SAME RwLock while the
write lock is still held. This deadlocks the thread permanently.

After 2-3 remember() calls, the server Mutex<Uteke> is held by the
deadlocked thread, making the entire server unresponsive (even
GET /health hangs).

Fix: explicitly `drop(index)` (the write guard) BEFORE calling
auto_link_cosine(). The index entry has already been inserted and
saved, so the write lock is no longer needed.

This also fixes the "no edges created" bug — auto_link_cosine was
never reaching the search/edge-creation code because it deadlocked
on the first read lock attempt.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 3cef39a into develop Jun 22, 2026
8 checks passed
@ajianaz
ajianaz deleted the fix/442-server-deadlock-auto-link branch June 22, 2026 10:36
ajianaz added a commit that referenced this pull request Aug 13, 2026
…res (#443)

Root cause: RwLock deadlock in remember_precomputed().

remember_precomputed() holds an RwLockWriteGuard on the vector index
(variable `index`). It then calls auto_link_cosine(), which tries to
acquire self.index.read() — a read lock on the SAME RwLock while the
write lock is still held. This deadlocks the thread permanently.

After 2-3 remember() calls, the server Mutex<Uteke> is held by the
deadlocked thread, making the entire server unresponsive (even
GET /health hangs).

Fix: explicitly `drop(index)` (the write guard) BEFORE calling
auto_link_cosine(). The index entry has already been inserted and
saved, so the write lock is no longer needed.

This also fixes the "no edges created" bug — auto_link_cosine was
never reaching the search/edge-creation code because it deadlocked
on the first read lock attempt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant