Repository navigation
Description
Bug Description
uteke-serve deadlocks when receiving multiple POST /remember requests. After 2-3 successful inserts, the server hangs indefinitely — subsequent POST /remember and GET /health requests timeout (60s+ with no response).
Additionally, cosine auto-linking (memory_edges) never fires — even for exact duplicate content that should score 1.0000 similarity.
Reproduction
Setup
# Fresh DB
rm ~/.uteke/uteke.db*
uteke-serve --port 8767 &Insert memories (via curl)
# 1st insert — succeeds after ONNX warmup (~5s)
curl -s -m 15 -X POST http://127.0.0.1:8767/remember \
-H "Content-Type: application/json" \
-d '{"content": "CorIn is a desktop knowledge workstation built with Tauri 2, Svelte 5, and Rust backend.", "namespace": "corin"}'
# 2nd insert — succeeds
curl -s -m 15 -X POST http://127.0.0.1:8767/remember \
-H "Content-Type: application/json" \
-d '{"content": "CorIn uses Tauri 2 framework with Svelte 5 frontend and Rust backend.", "namespace": "corin"}'
# 3rd insert — HANGS (timeout 60s+)
curl -s -m 15 -X POST http://127.0.0.1:8767/remember \
-H "Content-Type: application/json" \
-d '{"content": "Exact duplicate of memory 1.", "namespace": "corin"}'Server logs
INFO uteke_serve: POST /remember # 1st OK
INFO uteke_serve: POST /remember # 2nd OK
INFO uteke_serve: POST /remember # 3rd HANGS (no response, no error)
INFO uteke_serve: GET /health # Also hangs server fully unresponsive
Root Cause Analysis
1. Server Deadlock
The server uses Mutex<Uteke> (tokio::sync::Mutex). Each POST /remember acquires the lock for the entire duration of:
- Tokenize input
- ONNX inference (CPU-bound, ~100-200ms per call)
- SQLite insert
- VectorIndex insert + save
auto_link_cosine()VectorIndex search + SQLite edge insert
After 2-3 calls, the mutex appears to deadlock. Possible causes:
- ONNX session is
Mutex<Session>nested lock acquisition index.save()writes to disk while holding the Uteke lockauto_link_cosine()acquiresindex.read()lock, butindex.insert()in step 4 may not have released the write lock
2. No Auto-Edge Creation
Even when memories are successfully inserted, memory_edges table is always empty:
sqlite> SELECT COUNT(*) FROM memory_edges;
0The auto_link_cosine() function in edges.rs:766 is called after index.insert(), but:
index.search()returns empty results (indexsize() == 0check fails?)- Or namespace filter (
memories_in_namespace) returns empty set - Or the function silently returns on
results.is_empty()
Evidence
Two memories with cosine similarity 1.0000 (exact content match) but zero edges created:
Memory 1: "CorIn is a desktop knowledge workstation built with Tauri 2..."
Memory 2: "CorIn is a desktop knowledge workstation built with Tauri 2..."
Cosine similarity: 1.0000 (verified via /recall)
memory_edges: 0
3. Duplicate Insert Not Blocked
Exact same content can be inserted multiple times without any possible_duplicate warning or dedup. This confirms auto-linking is completely non-functional.
Impact
- CorIn semantic search shows irrelevant results without edges, graph is tag-based only
- Duplicate memories accumulate no dedup protection
- Server becomes unresponsive after a few operations, requires restart
- CorIn desktop app appears broken all searches hang
Expected Behavior
POST /remembershould complete in under 500ms (ONNX warm) and never hang- Exact duplicate content should create
possible_duplicateedge (sim >= 0.92) - Similar content should create
similar_toedge (sim >= 0.80) - Server should handle concurrent requests without deadlock
Environment
- uteke v0.3.2, schema v11
- macOS (Apple Silicon)
- uteke-serve from
cargo install --path crates/uteke-server - ONNX model: embeddinggemma-q4 (768d, 256 max seq len)
- DB: fresh
~/.uteke/uteke.db, 0 prior memories
Activity
fix(#442): server deadlock on remember + cosine auto-linking never fi…
ajianaz commentedon Jun 22, 2026
Fixed in #443. Root cause was RwLock deadlock: remember_precomputed() held the write lock on the vector index, then auto_link_cosine() tried to acquire a read lock on the same RwLock → permanent deadlock. Fix: drop(index) before calling auto_link_cosine().
release: v0.3.3 — critical deadlock fix (#444)
feat: MCP sync (13 tools) + dedup on insert + auto-aging + AGENT.md rule
feat: MCP sync (13 tools) + dedup on insert + auto-aging + AGENT.md rule
feat: MCP sync (13 tools) + dedup on insert + auto-aging + AGENT.md r…
release: v0.4.1 — MCP sync + dedup + auto-daemon + aging safety + nam…
fix(#442): server deadlock on remember + cosine auto-linking never fi…
release: v0.3.3 — critical deadlock fix (#444)
feat: MCP sync (13 tools) + dedup on insert + auto-aging + AGENT.md r…
release: v0.4.1 — MCP sync + dedup + auto-daemon + aging safety + nam…