← Back to Pull requests

fix(replica): persist snapshot's own name in its disk meta file #2014

Open
unknown opened this pull request with 218 lines diff across 2 files
View on GitHub
unknown unknown commented on Sep 08, 2026 02:33 UTC
Author

Which issue(s) this PR fixes:


Issue longhorn/longhorn#13728

What this PR does / why we need it:

After taking a snapshot, the persisted volume-snap-<name>.img.meta carries the previous head's filename in its Name field instead of the snapshot's own:

$ cat volume-snap-000.img.meta
{"Name":"volume-head-000.img","Parent":"","Removed":false,"UserCreated":true,...}

createDisk() reuses the old head's disk struct for the new snapshot, updates UserCreated, Created and Labels but not Name, then persists it. The later activeDiskData[...].Name = newSnapName corrects the same struct in memory, but only after the file was written. On reload readDiskData() takes Name from the filename, so only the on-disk file is wrong.

  • Name is now set with the other fields, before encodeToFile(); the redundant later assignment is removed.

  • The wrong Name incidentally recorded which head the snapshot was taken from. That is now kept explicitly in a new SourceHead field on disk, so the creation sequence stays available for reconstructing the chain (shuo-wu's point on the issue, requested in review).

  • The struct is still the current head's until the snapshot completes, so createDisk() keeps a copy and restores it in the existing rollback. A failed meta write (ENOSPC, say) leaves the head's Name/UserCreated/Created/Labels intact.
  • Meta files written by earlier versions are not rewritten; they load as before, with an empty SourceHead.

    TestSnapshotDiskMetaName and TestSnapshotMetaWriteFailureRollback cover both paths, including the persisted SourceHead.

    Special notes for your reviewer:

    None.

    Additional documentation or context

    Yes, AI-assisted; reviewed by me.

    Diff: 218 lines (+163 / -55) across 2 files Reviewer: KR-Ravindra Review duration: 44408m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 218 lines diff across 2 files
    0.37
    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%
    42%
    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.322
    Real PR Conversation Timeline
    1 comments
    "Review active on #2014"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 36.7% (MEDIUM) · Higher = larger blast radius
    36.7%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 20.9% · Safe to merge
    20.9%