Repository navigation
fix(cognition): embedding-cache eviction self-deadlock — a full cache silenced the whole citizenry - #2187
Merged
Conversation
…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
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.
The
if letscrutinee'siter()guard held the shard READ lock whileremovewaited 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