← Back to Pull requests

CNDB-20430: Keep memtable graph searchers from pinning released graphs #2864

Open
unknown opened this pull request with 178 lines diff across 2 files
View on GitHub
unknown unknown commented on Dec 02, 2026 14:20 UTC
Author

What is the issue


riptano/cndb#20430. CassandraOnHeapGraph caches one GraphSearcher per thread in a java.lang.ThreadLocal. Java keeps those values in each thread and clears stale entries only lazily, so after a memtable is flushed and its index is dropped, request threads that searched it keep the whole on-heap graph and its vectors reachable. Memtable accounting no longer counts that memory. A 10M-vector live load ran a 32 GB heap out of memory this way (5 flushed graphs, about 12.5 GB, held only by stale entries).

What does this PR fix and why was it fixed


  • CassandraOnHeapGraph.searchers is now an ExplicitThreadLocal, as in CassandraDiskAnn. Its per-thread searchers live in a map inside the graph object, so they are collected together with the graph.

  • New VectorMemtableIndexTest.releasedGraphIsNotPinnedBySearchThreads: searches from a thread that outlives the index, drops the index, and checks the graph is collected. It fails on main and passes with this change.

  • No JVector change; ExplicitThreadLocal is in the JVector version CC already uses.
  • Tests (Ice Lake, 32 cores, JDK 22): the 46 SAI vector test classes on this branch and on unmodified main. No new failures. VectorSiftSmallTest.testCompaction fails on both (recall 0.97 vs a 0.975 bar; main failed 3 of 3 reruns, this branch 1 of 3), and VectorKeyRestrictedOnPartitionTest timed out once on main only. Checkstyle passes.

    Diff: 178 lines (+133 / -45) across 2 files Reviewer: MarkWolters Review duration: 1090m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.35) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 178 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.310
    Real PR Conversation Timeline
    1 comments
    "Review active on #2864"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.5% (MEDIUM) · Higher = larger blast radius
    35.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%