Skip to content

fix(cognition): embedding-cache eviction self-deadlock — a full cache silenced the whole citizenry - #2187

Merged
joelteply merged 1 commit into
canaryfrom
fix/embedding-cache-eviction-self-deadlock
Aug 8, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/embedding-cache-eviction-self-deadlock

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The if let scrutinee's iter() guard held the shard READ lock while remove waited on the WRITE lock — self-deadlock, reachable only at EMBEDDING_CACHE_MAX, live-sampled as the cause of both solver stalls and citizen silence. Fix: bind the victim key first so the guard drops. Regression test on a private cache under timeout. VRAM-lease starvation of the embedder found on the same trail is #225, separate.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…roze every citizen's turns permanently

Sampled live (2026-08-08): both SWE solvers AND the room citizens went
silent; `sample` showed their tasks 100%-parked in
RecallFaculty → CachingEmbeddingProvider::embed → DashMap::remove →
lock_exclusive_slow. The eviction branch read

    if let Some(victim) = self.cache.map.iter().next().map(|e| *e.key()) {
        self.cache.map.remove(&victim);
    }

The `iter()` temporary holds the shard's READ lock for the whole `if let`
block (scrutinee temporary lifetime), so `remove` waits forever on the
same shard's WRITE lock — dashmap's documented never-do. Reachable only
when the cache sits at EMBEDDING_CACHE_MAX (20,000), which is why it
slept until production filled the cache today: from then on every novel
embed permanently parked its task, and recall embeds inside every turn.

Fix: bind the victim key in its own `let` so the iterator guard drops at
that statement's end, then remove. Regression test fills a PRIVATE cache
(existing with_cache seam — never the process-global map) to the cap and
embeds one novel text under a 5s timeout.

Also found on the same trail, filed separately (#225): the embedder's
1792MiB VRAM lease is refused with 604MiB governed-available after the
serving window grew — embedding is fully dead on this box even without
the deadlock; recall degrades to no-relevance.

cognition::embedding 17/17.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit 940233d into canary Aug 8, 2026
@joelteply
joelteply deleted the fix/embedding-cache-eviction-self-deadlock branch August 8, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant