From 02d06311f928fcb624d5655c22c12a67f4c313ba Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 15 Nov 2026 15:53:04 -0800 Subject: [PATCH] chunkstore: fork claims on the parent snapshot entry Replaces the separate hold objects with one conditional write on the parent attempt's own entry (codex01's design): - Fork adds its claim (target/request) to the entry before using it, conditioned on {state active, claims as read}; a deleting parent is refused. It removes its claim once its HEAD exists (or a sweep's tombstone settles the target). - Retain marks deleting only conditioned on {state active, gen, no claims}; a lost condition re-reads and decides again. Claims that can never matter (target has a HEAD, or its VOLUME is another request's) are cleared conditionally first; any other claim keeps the snapshot, with no lifetime. No listing, so no paging. - A dry run lists attempts a stopped pass left deleting, as apply frees them. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/frontend/chunkstore/catalog.go | 3 --- seaweed-block/core/frontend/chunkstore/retention.go | 11 +++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/catalog.go b/seaweed-block/core/frontend/chunkstore/catalog.go index e20a4b62f3..39f5dc737a 100644 --- a/seaweed-block/core/frontend/chunkstore/catalog.go +++ b/seaweed-block/core/frontend/chunkstore/catalog.go @@ -1297,9 +1297,6 @@ func (c *Catalog) claimForkParent(ctx context.Context, req ForkRequest) (Snapsho return SnapshotInfo{}, catErr(CodeSnapshotDeleting, false, nil, "snapshot %s/%s is being deleted", req.Source, req.Snapshot) } claims := decodeClaims(ref.entry) - if red := true; red { // RED: no claim written - return ref.info, nil - } for _, cl := range claims { if cl == token { return ref.info, nil diff --git a/seaweed-block/core/frontend/chunkstore/retention.go b/seaweed-block/core/frontend/chunkstore/retention.go index a10790b8a7..bff617f678 100644 --- a/seaweed-block/core/frontend/chunkstore/retention.go +++ b/seaweed-block/core/frontend/chunkstore/retention.go @@ -361,10 +361,8 @@ func (c *Catalog) Retain(ctx context.Context, vol string, dryRun bool) (Retentio } for _, s := range unfinished { d := RetentionDecision{Name: s.Name, Attempt: s.attempt, CreatedNs: s.CreatedNs, Class: s.Class, Pinned: s.Pinned(), Reasons: []string{SnapDeleting}} - if red := true; !red { // RED: unfinished attempts not listed - res.Decisions = append(res.Decisions, d) - res.Expired++ - } + res.Decisions = append(res.Decisions, d) + res.Expired++ expired = append(expired, d) } if dryRun { @@ -454,8 +452,9 @@ func (c *Catalog) deleteRetainedAttempt(ctx context.Context, vol, name, attempt next.Extended[extSnapState] = []byte(SnapDeleting) next.Extended[extSnapDeletedNs] = []byte(strconv.FormatInt(c.now().UnixNano(), 10)) err = c.f.UpdateEntry(ctx, dir, next, map[string][]byte{ - extSnapState: []byte(SnapActive), // RED: no claims condition - extSnapGen: e.Extended[extSnapGen], + extSnapState: []byte(SnapActive), + extSnapGen: e.Extended[extSnapGen], + extSnapClaims: nil, // no claims: a fork that claimed meanwhile wins }) if errors.Is(err, ErrPrecondition) || errors.Is(err, ErrNotFound) { continue // a claim, a delete or a replacement landed: decide again