← Back to Pull requests

fix(memiavl): fail the snapshot rewrite when a tree write panics #135

Closed
unknown closed this pull request without merging on Oct 08, 2026 13:53 UTC
View on GitHub
unknown unknown commented on Oct 07, 2026 22:08 UTC
Author

What

memiavl's MultiTree.WriteSnapshotWithContext now fails when a tree write panics, and it waits for every tree writer before it returns. It writes the trees through a new RunWorkerGroup helper instead of pond's GroupContext.

Issue

pond recovers a task's panic and only logs it. So when one tree's snapshot write panics, the rewrite counts it as a success. It writes the metadata and points current at a snapshot that is missing that tree. The next Commit fails with background snapshot rewriting failed: open .../current/<tree>/metadata: no such file or directory, and reopening the DB fails the same way. The node halts and can't restart without a manual fix.

There is a second bug. GroupContext.Wait returns as soon as its context is canceled, either by the caller or by the first failing task. The caller then goes on, and RewriteSnapshotWithContext removes the tmp dir while other writers are still running.

Solution

  • RunWorkerGroup runs one task per tree on a plain pond group and waits for all of them. A panic becomes an error that names the tree. The first failure cancels a derived context, so queued trees are skipped, as before. All errors are joined, so the log may also show one context canceled per skipped tree.

  • WriteSnapshotWithContext now also checks the caller's ctx after the wait, so a cancel is reported even when every write succeeded.

  • A failed background rewrite works as it already did: it is logged, the tmp dir is removed, current stays put and Commit goes on.

  • #107 has the same RunWorkerGroup, runWorkerTask and WriteSnapshotWithContext code, plus the same multitree tests. When #107 merges master, multitree.go and multitree_test.go auto-merge. #102 has its own wait-for-all version (no panic recovery). When it syncs, it should take this side and drop the sync import, as #107 does.
  • Diff: 235 lines (+176 / -59) across 2 files Reviewer: thomas-nguy Review duration: 945m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 235 lines diff across 2 files
    0.37
    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.327
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #135"
    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: 37.1% (MEDIUM) · Higher = larger blast radius
    37.1%
    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: 14.7% · Safe to merge
    14.7%