← Back to Pull requests

[MOD-18471] Fix SVS marked-deletion GC race #1082

Closed
unknown closed this pull request without merging on Oct 20, 2026 09:15 UTC
View on GitHub
unknown unknown commented on Oct 20, 2026 06:01 UTC
Author

Summary


  • protect every tiered backend deletion with mainIndexGuard shared

  • keep creation of a tombstone and its counter increment in the same GC epoch

  • add a deterministic tiered-index regression test for the post-compact deletion window
  • GC can finish compacting the SVS index, then a concurrent tiered deletion can increment num_marked_deleted before GC resets the counter to zero. The atomic counter prevents a C++ data race but the unconditional store still loses the logical update because the deletion path previously did not acquire either GC lock. The fix routes all tiered backend deletions through a helper that holds mainIndexGuard shared, while GC already holds that guard exclusively through compaction and the counter reset.

    Testing


  • regression test with the original unlocked implementation: fails because the post-compact deletion is not blocked

  • regression test with the fix: passes

  • existing markedDeleted, runGCAPI, and runGCInPlaceMode tests pass

  • clang-format dry run and git diff --check pass
  • The before/after tests were run in an isolated build using the repository-pinned SVS revision because the working tree's pre-existing SVS submodule checkout differs from the pinned commit.

    Supersedes #1081, which GitHub closed when its head branch was renamed.

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Changes concurrency around tiered SVS deletions and GC counter semantics; scope is localized but affects correctness of when reindex/GC is triggered.

    > Overview

    Fixes a logical race between tiered SVS garbage collection and backend deletions on num_marked_deleted: after compact(), GC could reset the counter to zero while a concurrent deletion (previously unlocked) still incremented it, so the new tombstone was effectively dropped.

    > Tiered SVS now routes every backend delete (deleteVector, in-place/async overwrites) through deleteVectorFromBackend, which takes a shared mainIndexGuard so deletions cannot interleave with GC’s exclusive hold through compact() and the counter reset. GC wrapper docs are updated to reflect that the guard also blocks backend deletions.

    > Test-only: SVSIndex::setAfterCompactCallbackForTest runs a hook after compact() and before the counter reset; a new unit test drives a concurrent deleteVector in that window and asserts it blocks until GC finishes, preserving the marked-deletion count across epochs.

    > <sup>Reviewed by Cursor Bugbot for commit 7692f8eb56864217187a3295d593a9f99ebbd3f1. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 339 lines (+254 / -85) across 4 files Reviewer: razdoburdin Review duration: 194m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 339 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1082"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.7% · Safe to merge
    16.7%