From eaf456d5e053b7418ea5c5ffb2d01bc2bfa9e8fe Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 1 Dec 2026 23:26:30 -0800 Subject: [PATCH] feat(chunkstore): resume delete intents and retire abandoned list pages --- .../cmd/blockvolume/chunk_maintenance.go | 4 +- .../testdata/maintenance-retention-only.json | 2 + .../core/frontend/chunkstore/clean_b.go | 44 +++- .../frontend/chunkstore/clean_intent_b.go | 22 ++ .../chunkstore/clean_intent_b_test.go | 167 ++++++++++++++++ .../frontend/chunkstore/clean_lists_b_test.go | 188 ++++++++++++++++++ .../frontend/durable/maintenance_status.go | 2 + .../docs/design/immutable-list-pages.md | 29 ++- seaweed-block/docs/design/invariants.md | 6 +- seaweed-block/docs/status-schema.md | 2 + 10 files changed, 456 insertions(+), 10 deletions(-) create mode 100644 seaweed-block/core/frontend/chunkstore/clean_intent_b.go create mode 100644 seaweed-block/core/frontend/chunkstore/clean_intent_b_test.go create mode 100644 seaweed-block/core/frontend/chunkstore/clean_lists_b_test.go diff --git a/seaweed-block/cmd/blockvolume/chunk_maintenance.go b/seaweed-block/cmd/blockvolume/chunk_maintenance.go index a42cdc86fd..975d3fa189 100644 --- a/seaweed-block/cmd/blockvolume/chunk_maintenance.go +++ b/seaweed-block/cmd/blockvolume/chunk_maintenance.go @@ -58,13 +58,13 @@ func newChunkMaintenance(cat *chunkstore.BCatalog, ref chunkstore.VolumeRef, cle diagnostic = "HEAD generation not read: HEAD absent" } defer func() { - durable.ReportMaintenance(ctx, durable.MaintenancePassStatus{SkipReason: head.ListRetirementSkipReason(), Planned: int64(res.Planned), Removed: int64(res.Removed), PlannedChunks: int64(res.PlannedChunks), PlannedRoots: int64(res.PlannedRoots), PlannedSegments: int64(res.PlannedSegments), RemovedChunks: int64(res.Removed - res.Roots - res.Segments), RemovedRoots: int64(res.Roots), RemovedSegments: int64(res.Segments), HeadGen: head.Gen, HeadGenError: diagnostic}) + durable.ReportMaintenance(ctx, durable.MaintenancePassStatus{SkipReason: head.ListRetirementSkipReason(), Planned: int64(res.Planned), Removed: int64(res.Removed), PlannedChunks: int64(res.PlannedChunks), PlannedRoots: int64(res.PlannedRoots), PlannedSegments: int64(res.PlannedSegments), RemovedChunks: int64(res.Removed - res.Roots - res.Segments - res.Lists), RemovedRoots: int64(res.Roots), RemovedSegments: int64(res.Segments), PlannedLists: int64(res.PlannedLists), RemovedLists: int64(res.Lists), HeadGen: head.Gen, HeadGenError: diagnostic}) }() var rerr error res, rerr = cat.RemoveUnreachableAll(ctx, ref, me, s) return rerr }) - log.Printf("blockvolume: maintenance volume=%s clean=%s shards=%d planned=%d removed=%d removedChunks=%d removedRoots=%d removedSegments=%d plannedChunks=%d plannedRoots=%d plannedSegments=%d", vol, session, res.Shards, res.Planned, res.Removed, res.Removed-res.Roots-res.Segments, res.Roots, res.Segments, res.PlannedChunks, res.PlannedRoots, res.PlannedSegments) + log.Printf("blockvolume: maintenance volume=%s clean=%s shards=%d planned=%d removed=%d removedChunks=%d removedRoots=%d removedSegments=%d plannedChunks=%d plannedRoots=%d plannedSegments=%d plannedLists=%d removedLists=%d", vol, session, res.Shards, res.Planned, res.Removed, res.Removed-res.Roots-res.Segments-res.Lists, res.Roots, res.Segments, res.PlannedChunks, res.PlannedRoots, res.PlannedSegments, res.PlannedLists, res.Lists) // A cleaning refused because HEAD moved away from this holder is // the same fence a cut would see: classified so the provider latches. return chunkstore.LayoutErr(err) diff --git a/seaweed-block/cmd/blockvolume/testdata/maintenance-retention-only.json b/seaweed-block/cmd/blockvolume/testdata/maintenance-retention-only.json index 471b88ad5f..cd61734030 100644 --- a/seaweed-block/cmd/blockvolume/testdata/maintenance-retention-only.json +++ b/seaweed-block/cmd/blockvolume/testdata/maintenance-retention-only.json @@ -9,9 +9,11 @@ "plannedChunks": 0, "plannedRoots": 0, "plannedSegments": 0, + "plannedLists": 0, "removedChunks": 0, "removedRoots": 0, "removedSegments": 0, + "removedLists": 0, "error": "", "headGenError": "", "headGen": 0 diff --git a/seaweed-block/core/frontend/chunkstore/clean_b.go b/seaweed-block/core/frontend/chunkstore/clean_b.go index bcca9bb8b7..41275b8783 100644 --- a/seaweed-block/core/frontend/chunkstore/clean_b.go +++ b/seaweed-block/core/frontend/chunkstore/clean_b.go @@ -20,9 +20,11 @@ type CleanResult struct { PlannedChunks int PlannedRoots int PlannedSegments int + PlannedLists int Removed int Roots int Segments int + Lists int } // The cursor is scheduling only: after a timeout a new session re-plans tags @@ -35,6 +37,7 @@ type cleanCursor struct { after string segmentAfter string poolAfter string + listAfter string } func (c *BCatalog) cleaningCursor(v VolumeRef) *cleanCursor { @@ -51,8 +54,10 @@ func (c *BCatalog) cleaningCursor(v VolumeRef) *cleanCursor { return cur } -// RemoveUnreachableAll resumes a bounded cleaning. Roots are removed before -// segments, then chunks; interruptions leave only unnamed content behind. +// RemoveUnreachableAll resumes a paged full sweep. Roots are removed before +// segments, then chunks and unreachable list pages. This remains proportional +// to the namespace, not the number of changes; interruptions leave unnamed +// content for a later pass. func (c *BCatalog) RemoveUnreachableAll(ctx context.Context, v VolumeRef, me layout.HolderID, session string) (res CleanResult, err error) { cur := c.cleaningCursor(v) if !cur.mu.TryLock() { @@ -164,6 +169,39 @@ func (c *BCatalog) RemoveUnreachableAll(ctx context.Context, v VolumeRef, me lay } } } - cur.phase, cur.shard, cur.after, cur.poolAfter = 0, "", "", "" + // Retire metadata only after the data sweep. A current continuation is + // protected by Cleaner.Page's complete-chain reachability check; being in + // an abandoned producer's chain is never removal authority. + for { + if err := ctx.Err(); err != nil { + return res, err + } + entries, err := c.f.ListEntries(ctx, path.Join(c.base, v.Dir(), layout.ListDir), "", cur.listAfter, cleanPage) + if err != nil { + return res, err + } + names := make([]string, 0, len(entries)) + for _, e := range entries { + if e == nil || e.IsDirectory || e.Name <= cur.listAfter { + return res, layout.ErrCorrupt + } + names = append(names, e.Name) + } + res.Planned += len(names) + res.PlannedLists += len(names) + out, err := cleaner.Page(ctx, layout.ListDir, 0, names) + res.Removed += len(out.Names) + res.Lists += len(out.Names) + if out.After != "" { + cur.listAfter = path.Base(out.After) + } + if err != nil { + return res, err + } + if uint32(len(names)) < cleanPage { + break + } + } + cur.phase, cur.shard, cur.after, cur.poolAfter, cur.listAfter = 0, "", "", "", "" return res, nil } diff --git a/seaweed-block/core/frontend/chunkstore/clean_intent_b.go b/seaweed-block/core/frontend/chunkstore/clean_intent_b.go new file mode 100644 index 0000000000..27188303b4 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/clean_intent_b.go @@ -0,0 +1,22 @@ +package chunkstore + +import ( + "context" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +// CleanSnapshotDeletePage resumes one persisted snapshot-delete page. pending +// reports whether HEAD still names work, only when err is nil. The driver does +// not claim a holder, infer a target from a receipt, or enumerate the namespace. +func (c *BCatalog) CleanSnapshotDeletePage(ctx context.Context, v VolumeRef) (pending bool, err error) { + s, r, err := c.open(v) + if err != nil { + return false, err + } + h, err := layout.RunConsumeSnapshotDeleteIntent(ctx, s, r) + if err != nil { + return false, err + } + return h.List != nil, nil +} diff --git a/seaweed-block/core/frontend/chunkstore/clean_intent_b_test.go b/seaweed-block/core/frontend/chunkstore/clean_intent_b_test.go new file mode 100644 index 0000000000..ed9fd287ae --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/clean_intent_b_test.go @@ -0,0 +1,167 @@ +package chunkstore + +import ( + "context" + "errors" + "path" + "sort" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +type intentNamespaceProbe struct { + Filer + calls int +} + +var errIntentCursorInterrupted = errors.New("interrupted intent cursor update") + +type intentCursorFault struct { + Filer + afterWrite bool + armed bool + deletes map[string]int +} + +func (f *intentCursorFault) UpdateEntry(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte) error { + if e.Name == layout.HeadName && f.armed { + f.armed = false + if f.afterWrite { + if err := f.Filer.UpdateEntry(ctx, dir, e, expected); err != nil { + return err + } + } + return errIntentCursorInterrupted + } + return f.Filer.UpdateEntry(ctx, dir, e, expected) +} + +func (f *intentCursorFault) DeleteEntry(ctx context.Context, dir, name string, expected map[string][]byte) error { + err := f.Filer.DeleteEntry(ctx, dir, name, expected) + if err == nil && path.Base(path.Dir(dir)) == layout.PoolDir { + f.deletes[name]++ + } + return err +} + +func TestCatalogIntentCursorInterruptAndLostReply(t *testing.T) { + for _, afterWrite := range []bool{false, true} { + name := "before cursor write" + if afterWrite { + name = "lost reply after cursor write" + } + t.Run(name, func(t *testing.T) { + ctx := context.Background() + c, v, s, orphans := pendingIntentCatalog(t) + before, _, err := s.ReadHead(ctx) + if err != nil { + t.Fatal(err) + } + fault := &intentCursorFault{Filer: c.f, armed: true, afterWrite: afterWrite, deletes: map[string]int{}} + c.f = fault + pending, err := c.CleanSnapshotDeletePage(ctx, v) + if afterWrite { + if err != nil || !pending { + t.Fatalf("lost reply not settled: pending=%v err=%v", pending, err) + } + } else if !errors.Is(err, errIntentCursorInterrupted) { + t.Fatalf("unfinished cursor update became success: pending=%v err=%v", pending, err) + } + current, _, readErr := s.ReadHead(ctx) + if readErr != nil || (!afterWrite && current.List.Ref != before.List.Ref) || (afterWrite && current.List.Ref == before.List.Ref) { + t.Fatalf("wrong persisted continuation: before=%+v after=%+v err=%v", before.List, current.List, readErr) + } + if present(t, s, orphans[0]) || !present(t, s, orphans[1]) { + t.Fatal("effects did not precede the cursor write, or the unread tail was executed") + } + restarted, err := NewBCatalog(fault, c.b, c.base) + if err != nil { + t.Fatal(err) + } + if !afterWrite { + if pending, err := restarted.CleanSnapshotDeletePage(ctx, v); err != nil || !pending { + t.Fatalf("unfinished page retry: pending=%v err=%v", pending, err) + } + } + if pending, err := restarted.CleanSnapshotDeletePage(ctx, v); err != nil || pending { + t.Fatalf("tail retry: pending=%v err=%v", pending, err) + } + for _, n := range orphans { + if present(t, s, n) || fault.deletes[n.String()] != 1 { + t.Fatalf("chunk %s: present=%v delete_effects=%d", n, present(t, s, n), fault.deletes[n.String()]) + } + } + }) + } +} + +func (p *intentNamespaceProbe) ListEntries(context.Context, string, string, string, uint32) ([]*filerpb.Entry, error) { + p.calls++ + return nil, errors.New("intent consumer must not enumerate unrelated namespace objects") +} + +func pendingIntentCatalog(t *testing.T) (*BCatalog, VolumeRef, *LayoutStore, []layout.ChunkName) { + t.Helper() + ctx := context.Background() + c, v, s, orphans := cleanFixture(t) + h, _, err := s.ReadHead(ctx) + if err != nil { + t.Fatal(err) + } + stamped, _, err := h.StampSnapshotGenerations() + if err != nil { + t.Fatal(err) + } + if err := s.UpdateHead(ctx, h.Gen, stamped, layout.CauseSnapshotUnchanged); err != nil { + t.Fatal(err) + } + h, _, err = s.ReadHead(ctx) + if err != nil { + t.Fatal(err) + } + p := layout.ListPage{VolumeID: v.ID, Kind: layout.ListSnapshotDeleteIntent, Producer: "delete-s", Generation: h.Gen + 1, Pages: 1, + Target: &layout.SnapshotTarget{Name: "s", Gen: h.Snapshots["s"].Gen}, Entries: []string{orphans[1].Path()}} + tail, err := layout.StageSnapshotDeletePage(ctx, s, h.Gen, p) + if err != nil { + t.Fatal(err) + } + p.Pages, p.Next = 2, &tail + p.Entries = []string{h.Snapshots["s"].Root.Path(), orphans[0].Path()} + sort.Strings(p.Entries) + head, err := layout.StageSnapshotDeletePage(ctx, s, h.Gen, p) + if err != nil { + t.Fatal(err) + } + cursor := layout.ListCursor{Ref: head, Kind: p.Kind, Producer: p.Producer, Generation: p.Generation, Target: p.Target} + if _, err := layout.RunDeleteSnapshotWithIntent(ctx, s, h.Gen, cursor); err != nil { + t.Fatal(err) + } + return c, v, s, orphans +} + +func TestCatalogDeleteIntentResumesOnePageWithoutNamespaceScan(t *testing.T) { + ctx := context.Background() + c, v, s, orphans := pendingIntentCatalog(t) + probe := &intentNamespaceProbe{Filer: c.f} + c.f = probe + pending, err := c.CleanSnapshotDeletePage(ctx, v) + if err != nil || !pending || present(t, s, orphans[0]) || !present(t, s, orphans[1]) { + t.Fatalf("first page: pending=%v first=%v tail=%v err=%v", pending, present(t, s, orphans[0]), present(t, s, orphans[1]), err) + } + // Reconstruct the entire catalog; the next page comes only from HEAD, not + // from the previous process, a receipt, or a volatile scheduling cursor. + restarted, err := NewBCatalog(probe, c.b, c.base) + if err != nil { + t.Fatal(err) + } + pending, err = restarted.CleanSnapshotDeletePage(ctx, v) + if err != nil || pending || present(t, s, orphans[1]) || probe.calls != 0 { + t.Fatalf("resume: pending=%v tail=%v namespace_calls=%d err=%v", pending, present(t, s, orphans[1]), probe.calls, err) + } + h, _, err := s.ReadHead(ctx) + if err != nil || h.Current == nil || h.Holder != cleanHolder.Holder || h.ClaimID != cleanHolder.ClaimID { + t.Fatalf("consumer changed ownership/current root: %+v %v", h, err) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/clean_lists_b_test.go b/seaweed-block/core/frontend/chunkstore/clean_lists_b_test.go new file mode 100644 index 0000000000..7fa933a2d1 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/clean_lists_b_test.go @@ -0,0 +1,188 @@ +package chunkstore + +import ( + "context" + "errors" + "path" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +// The compatibility sweep must retire abandoned list metadata too. Otherwise +// retrying publication can leave an unbounded metadata backlog even when no +// candidate data objects remain. +func TestBCatalogFullSweepRetiresUnreachableListPages(t *testing.T) { + ctx := context.Background() + c, v, s, _ := cleanFixture(t) + p := layout.ListPage{VolumeID: v.ID, Kind: layout.ListDrop, Producer: "abandoned", Generation: 1, Pages: 1, + Entries: []string{(layout.RootName{Hash: layout.Sum([]byte("unpublished root"))}).Path()}} + raw, err := p.Encode() + if err != nil { + t.Fatal(err) + } + ref, err := p.Ref() + if err != nil { + t.Fatal(err) + } + rel, _ := ref.Path() + if err := layout.EnsureObject(ctx, s, rel, raw, p.Producer); err != nil { + t.Fatal(err) + } + if _, _, err := cleanVia(ctx, c, v, cleanHolder); err != nil { + t.Fatal(err) + } + if _, found, err := s.ReadListPage(ctx, ref); err != nil || found { + t.Fatalf("abandoned page survived the compatibility sweep: found=%v err=%v", found, err) + } +} + +type listSweepProbe struct { + Filer + listCalls int + failAt int + limits []uint32 + deletes map[string]int +} + +var errListSweepInterrupted = errors.New("list sweep interrupted after a completed page") + +func (p *listSweepProbe) ListEntries(ctx context.Context, dir, prefix, after string, limit uint32) ([]*filerpb.Entry, error) { + if path.Base(dir) == layout.ListDir { + p.listCalls++ + p.limits = append(p.limits, limit) + if p.failAt == p.listCalls { + return nil, errListSweepInterrupted + } + } + return p.Filer.ListEntries(ctx, dir, prefix, after, limit) +} + +func (p *listSweepProbe) DeleteEntry(ctx context.Context, dir, name string, expected map[string][]byte) error { + err := p.Filer.DeleteEntry(ctx, dir, name, expected) + if err == nil && path.Base(dir) == layout.ListDir { + p.deletes[name]++ + } + return err +} + +func TestBCatalogListRetirementResumesAfterRestart(t *testing.T) { + ctx := context.Background() + previousPage := cleanPage + cleanPage = 1 + t.Cleanup(func() { cleanPage = previousPage }) + c, v, s, _ := cleanFixture(t) + probe := &listSweepProbe{Filer: c.f, failAt: 2, deletes: map[string]int{}} + c.f = probe + var refs []layout.ListRef + for _, producer := range []string{"abandoned-a", "abandoned-b", "abandoned-c"} { + p := layout.ListPage{VolumeID: v.ID, Kind: layout.ListDrop, Producer: producer, Generation: 1, Pages: 1, + Entries: []string{(layout.RootName{Hash: layout.Sum([]byte(producer))}).Path()}} + raw, err := p.Encode() + if err != nil { + t.Fatal(err) + } + ref, err := p.Ref() + if err != nil { + t.Fatal(err) + } + rel, _ := ref.Path() + if err := layout.EnsureObject(ctx, s, rel, raw, producer); err != nil { + t.Fatal(err) + } + refs = append(refs, ref) + } + res, _, err := cleanVia(ctx, c, v, cleanHolder) + if !errors.Is(err, errListSweepInterrupted) || res.Lists != 1 || len(probe.deletes) != 1 { + t.Fatalf("first page was not durably reclaimed before interruption: result=%+v deletes=%v err=%v", res, probe.deletes, err) + } + // No scheduling cursor survives: a new catalog must still finish from the + // same filer state, without deleting a completed page a second time. + restarted, err := NewBCatalog(probe, c.b, c.base) + if err != nil { + t.Fatal(err) + } + probe.failAt = 0 + res, _, err = cleanVia(ctx, restarted, v, cleanHolder) + if err != nil || res.Lists != 2 || res.PlannedLists != 2 { + t.Fatalf("restart: result=%+v err=%v", res, err) + } + for _, ref := range refs { + if probe.deletes[ref.Hash] != 1 { + t.Fatalf("page %s deleted %d times", ref.Hash, probe.deletes[ref.Hash]) + } + } + for _, limit := range probe.limits { + if limit != 1 { + t.Fatalf("unbounded list enumeration: limit=%d", limit) + } + } +} + +func TestBCatalogFullSweepKeepsTheEntireCurrentList(t *testing.T) { + for _, missingTail := range []bool{false, true} { + name := "current chain" + if missingTail { + name = "missing continuation" + } + t.Run(name, func(t *testing.T) { + ctx := context.Background() + c, v, s, _ := cleanFixture(t) + h, found, err := s.ReadHead(ctx) + if err != nil || !found { + t.Fatalf("HEAD: %v %v", found, err) + } + put := func(p layout.ListPage) layout.ListRef { + t.Helper() + raw, err := p.Encode() + if err != nil { + t.Fatal(err) + } + ref, err := p.Ref() + if err != nil { + t.Fatal(err) + } + rel, _ := ref.Path() + if err := layout.EnsureObject(ctx, s, rel, raw, p.Producer); err != nil { + t.Fatal(err) + } + return ref + } + page := layout.ListPage{VolumeID: v.ID, Kind: layout.ListDrop, Producer: "current", Generation: h.Gen + 1, Pages: 1, + Entries: []string{(layout.RootName{Hash: layout.Sum([]byte("tail candidate"))}).Path()}} + tail := put(page) + page.Pages, page.Next = 2, &tail + page.Entries = []string{(layout.RootName{Hash: layout.Sum([]byte("head candidate"))}).Path()} + head := put(page) + h.Version = layout.HeadVersion1 + h.List = &layout.ListCursor{Ref: head, Kind: page.Kind, Producer: page.Producer, Generation: page.Generation} + if err := s.UpdateHead(ctx, h.Gen, h, layout.CauseListPublish); err != nil { + t.Fatal(err) + } + page.Pages, page.Next, page.Producer = 1, nil, "abandoned" + orphan := put(page) + if missingTail { + rel, _ := tail.Path() + if err := c.f.DeleteEntry(ctx, s.root+"/"+layout.ListDir, rel[len(layout.ListDir)+1:], nil); err != nil { + t.Fatal(err) + } + } + _, _, err = cleanVia(ctx, c, v, cleanHolder) + if missingTail { + if !errors.Is(err, layout.ErrListPageMissing) { + t.Fatalf("missing continuation completed the sweep: %v", err) + } + } else if err != nil { + t.Fatal(err) + } + for _, ref := range []layout.ListRef{head, tail, orphan} { + _, found, err := s.ReadListPage(ctx, ref) + want := ref != orphan && (!missingTail || ref != tail) || missingTail && ref == orphan + if err != nil || found != want { + t.Fatalf("page %s: found=%v want=%v err=%v", ref.Hash, found, want, err) + } + } + }) + } +} diff --git a/seaweed-block/core/frontend/durable/maintenance_status.go b/seaweed-block/core/frontend/durable/maintenance_status.go index 6d377c6ed4..0508610cb1 100644 --- a/seaweed-block/core/frontend/durable/maintenance_status.go +++ b/seaweed-block/core/frontend/durable/maintenance_status.go @@ -26,9 +26,11 @@ type MaintenancePassStatus struct { PlannedChunks int64 `json:"plannedChunks"` // chunk objects considered for removal PlannedRoots int64 `json:"plannedRoots"` // root objects considered for removal PlannedSegments int64 `json:"plannedSegments"` // segment objects considered for removal + PlannedLists int64 `json:"plannedLists"` // immutable list pages considered for removal RemovedChunks int64 `json:"removedChunks"` // chunk objects removed RemovedRoots int64 `json:"removedRoots"` // root objects removed RemovedSegments int64 `json:"removedSegments"` // segment objects removed + RemovedLists int64 `json:"removedLists"` // immutable list pages removed Error string `json:"error"` // one-line callback error; empty when the callback completed HeadGenError string `json:"headGenError"` // diagnostic HEAD read error; empty when read HeadGen uint64 `json:"headGen"` // observed cleaning HEAD generation; diagnostic only diff --git a/seaweed-block/docs/design/immutable-list-pages.md b/seaweed-block/docs/design/immutable-list-pages.md index 3339f4a829..fc3bb4a8cf 100644 --- a/seaweed-block/docs/design/immutable-list-pages.md +++ b/seaweed-block/docs/design/immutable-list-pages.md @@ -61,8 +61,20 @@ fields, kind confusion, identity/hash mismatch, counts, canonical ordering, forbidden paths and size/entry limits. Unknown newer versions are refused. The fallback cleaner stays a full mark/sweep until a separately reviewed -switch, made safe for reachable list/intent objects. Nothing in this codec -starts that switch or weakens existing reclamation protections. +switch. Its catalog pass now also enumerates `lists/` in bounded pages after +the root, segment and chunk phases, using the same holder/session and +conditional removal guards. It authenticates the whole HEAD-reachable chain +before removing any candidate page, preserving shared tails; a missing +continuation stops retirement. A restarted catalog can re-enumerate from the +beginning: completed deletions are absent and cannot be deleted again. The +in-memory cursor only schedules retries; it grants no reclamation authority. +Maintenance totals include list pages, with separate `plannedLists` and +`removedLists` counters so they never count as chunks. + +This is the compatibility sweep, not the by-change switch. Complete V8 +producer/consumer activation, restore-source and volume-delete progress +integration, and their crash/counting qualification remain required. No +proportional-to-changes claim is made for this full namespace scan. ## Publication, continuation and retirement ```mermaid @@ -196,6 +208,19 @@ new authority branch require exact-head model/code review before activation. No product delete driver calls this seam yet. The one-slot admission capacity, remaining producer wiring and Linux/race qualification remain outstanding. +The catalog exposes `CleanSnapshotDeletePage` for an executor to resume exactly +one page from the current durable intent. It reconstructs the store and reader +from the full volume reference and delegates to the same guarded consumer; +it neither claims the volume nor looks up a receipt. `pending` is meaningful +only on success. No directory listing is used, and an unread tail is left for +the next call. A failed cursor CAS leaves that page pending; a lost reply is +settled from HEAD. The catalog restart controls count actual conditional +deletions and require each completed object to be deleted once. Live-root +reachability still has its existing manifest-read cost: absence of namespace +enumeration is not a claim that the whole path is proportional to changes. +Automatic maintenance and general drop/upload-intent producer wiring are not +enabled by exposing this catalog entry point. + The generic `StageListPage` rejects snapshot-delete intent before any HEAD or object I/O, just as generic publication and consumption reject that kind. Its ordinary EnsureObject adoption must never restore a snapshot-intent producer diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 6b8b585bc7..3ff61470ec 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -585,7 +585,7 @@ stateDiagram-v2 | clean(c), current list page | clean(c), next continuation or none | exact observed cursor CAS only after authenticated page effects succeed; failed reads and failed effects leave cursor unchanged | `list_chain.go` `RunAdvanceList` | `INV-LIST-CURSOR-001` | | clean(c), stored list page | clean(c), unreached page removed | tags before HEAD; current clean session; spare all current-chain pages; conditional mark then delete | `remove.go` `Cleaner.Page` | `INV-LIST-RETIRE-001` | | idle/snap, retained snapshot | same activity, row removed and intent published | one CAS removes only captured name/gen and names its durable chain; each page present, this attempt's tag, unmarked; clean activity refuses | `delete_intent.go` `RunDeleteSnapshotWithIntent` | `INV-SNAPSHOT-DELETE-INTENT-001`, `INV-SNAPSHOT-DELETE-ADOPT-001` | -| idle live/detached, persisted delete intent | idle live/detached, next intent page or none | receipt-independent continuation from current HEAD; live-root and conditional effect guards; cursor follows completed effects | `delete_intent.go` `RunConsumeSnapshotDeleteIntent` | `INV-SNAPSHOT-DELETE-CONSUME-001` | +| idle live/detached, persisted delete intent | idle live/detached, next intent page or none | receipt-independent continuation from current HEAD; live-root and conditional effect guards; cursor follows completed effects | `delete_intent.go` `RunConsumeSnapshotDeleteIntent`; `BCatalog.CleanSnapshotDeletePage` | `INV-SNAPSHOT-DELETE-CONSUME-001` | | idle | snap(s) | caller is the holder at HEAD's epoch (epoch, server and claim id); HEAD present; snap(s) again is a replay, any other activity is refused | head.go `Head.Begin`, `runTransition` | `INV-SNAPK-HEAD-WRITE-001`, `INV-SNAPK-BEGIN-001` | | snap(s) | idle | holder at HEAD's epoch (epoch, server and claim id); activity is snap(s); over idle it succeeds without a write and means only that no activity remains; before resuming a failed stop, abort its still-open session and re-read HEAD: only matching live/idle resumes, detached goes Down, absent/unknown stays stopped | head.go `Head.Abort`; durable/provider_layout.go `settleLayoutStop` | `INV-SNAPK-ABORT-001` | | snap(s) | idle, current = root | holder at HEAD's epoch (epoch, server and claim id); activity is snap(s); the previous manifest builds to HEAD's current root; the new own chunks, every segment and the root are present; a new snapshot name records bounded retention facts once, while replay preserves them | commit.go `Head.Commit`, `RunCommit` | `INV-SNAPK-COMMIT-REACH-001`, `INV-SNAPK-TXN-INTERRUPT-001`, `INV-SNAPK-SNAPSHOT-META-001` | @@ -1306,9 +1306,9 @@ Notes: | `INV-LIST-RESERVED-001` | Version-1 HEAD preserves at most three additional checked list cursors without consuming them or refusing serving; list-page retirement remains conservative while they are present and reports newer_pending_work. | M9 all existing HEAD updates | `core/frontend/chunkstore/layout/head.go` `check`, `clone`; `core/frontend/chunkstore/layout/remove.go` `Cleaner.Page` | `TestMaintenanceStatusRealPassAndTimeout/newer-pending-work`, `TestReservedListsGoldenBytes`, `TestReservedListsValidationAndClone`, `TestReservedListsCloneDoesNotAlias`, `TestReservedListsDoNotBecomeCompatibilitySweepCandidates`, `TestMachineReadableHeadCensusCoversRealTransitionFieldSets`, `TestListWritesMatchExportedCensus` | ProducerSeam r1 E1-E3: Bounded, NoLeak, NoDangling (encoding only; producer deferred) | DORMANT | | `INV-LIST-PUBLISH-001` | A list publication names only durable authenticated pages of its open session; an unknown reply never abandons their protection. | M9 snap -> snap | `list_chain.go` `StageListPage`, `RunPublishList` | `TestPublishList_Closure`, `TestRunPublishList_InterruptAtEveryStep`, `TestListSessionEndedDuringPageWriteCannotPublish` | PageChain 246-250; NoDangling | DORMANT | | `INV-LIST-CURSOR-001` | The persisted list cursor advances only after its authenticated page's idempotent effects finish; a missing page never completes work. | M9 clean -> clean | `list_chain.go` `RunAdvanceList` | `TestAdvanceList_Closure`, `TestRunAdvanceList_InterruptAtEveryStep`, `TestListMissingConsumerPageNeverCompletes` | PageChain 246,251-253; NoLostWork | DORMANT | -| `INV-LIST-RETIRE-001` | List-page removal requires a clean session and the existing conditional mark/delete order; every page reached by HEAD is spared, including shared tails. | M9 clean removal | `remove.go` `Cleaner.removePlanned` | `TestListSweepSpareSessionAndReachableTail`, `TestListSharedTailSurvivesAbandonedChainAndResumes`, `TestLayoutStoreListPublishConsumeAndRetire` | PageChain 246,248-251; NoDangling | DORMANT | +| `INV-LIST-RETIRE-001` | List-page removal requires a clean session and the existing conditional mark/delete order; every page reached by HEAD is spared, including shared tails. | M9 clean removal | `remove.go` `Cleaner.removePlanned`; `clean_b.go` compatibility sweep | `TestListSweepSpareSessionAndReachableTail`, `TestListSharedTailSurvivesAbandonedChainAndResumes`, `TestLayoutStoreListPublishConsumeAndRetire`, `TestBCatalogFullSweepKeepsTheEntireCurrentList`, `TestBCatalogListRetirementResumesAfterRestart` | PageChain 246,248-251; NoDangling | DORMANT | | `INV-SNAPSHOT-DELETE-INTENT-001` | Removing a captured snapshot incarnation and publishing its durable intent are one HEAD CAS; an unrelated metadata retry keeps the same target and durable pages. | M9 metadata delete | `delete_intent.go` `RunDeleteSnapshotWithIntent` | `TestDeleteSnapshotWithIntent_Closure`, `TestRunDeleteSnapshotWithIntent_InterruptAtEveryStep`, `TestDeleteIntentRetryKeepsDurablePagesAcrossMetadataCAS` | SnapDelete 241-245; PageChain 246-249 | DORMANT | -| `INV-SNAPSHOT-DELETE-CONSUME-001` | Only current persisted delete intent authorizes offline reclamation; live roots remain protected, failed effects retain the cursor, and receipt retirement cannot erase work. | M9 idle intent continuation | `delete_intent.go`; `remove.go` `Cleaner.removePlanned` | `TestConsumeSnapshotDeleteIntent_Closure`, `TestDeleteIntentOfflineAndReplacementPreserved`, `TestDeleteIntentMarkConflictKeepsUnfinishedPage`, `TestLayoutSnapshotDeleteIntentResumesWithoutReceipt` | PageChain 246,251-253; offline authority refinement awaits model/code read | DORMANT | +| `INV-SNAPSHOT-DELETE-CONSUME-001` | Only current persisted delete intent authorizes offline reclamation; live roots remain protected, failed effects retain the cursor, and receipt retirement cannot erase work. | M9 idle intent continuation | `delete_intent.go`; `remove.go` `Cleaner.removePlanned` | `TestConsumeSnapshotDeleteIntent_Closure`, `TestDeleteIntentOfflineAndReplacementPreserved`, `TestDeleteIntentMarkConflictKeepsUnfinishedPage`, `TestLayoutSnapshotDeleteIntentResumesWithoutReceipt`, `TestCatalogDeleteIntentResumesOnePageWithoutNamespaceScan`, `TestCatalogIntentCursorInterruptAndLostReply` | PageChain 246,251-253; offline authority refinement awaits model/code read | DORMANT | | `INV-SNAPSHOT-DELETE-ADOPT-001` | Publication adopts every intent page with a fresh CAS-base tag and checks it is present, this attempt's and unmarked; stale cleaners/adopters cannot remove or retag a published page, and staging never restores old tags. | M9 delete intent publication | `delete_intent.go` `adoptDeleteIntentPage`, `RunDeleteSnapshotWithIntent`, `StageSnapshotDeletePage` | `TestDeleteIntentRefreshedBaseFencesDelayedCleanerMark`, `TestDeleteIntentRefreshedBaseFencesDelayedCleanerDelete`, `TestDeleteIntentAdoptionCannotRestoreStaleTags`, `TestDeleteIntentStagingNeverRevertsPublishedTags`, `TestDeleteIntentPublicationChecksAdoptedPageMetadata`, `TestGenericIntentStagingCannotUndoRefreshedPublication` | StaleClean 159-161; exact-head refinement read required | DORMANT | The routine full-sweep scope of `INV-SNAPK-REMOVE-MARK-001` is explicit here: diff --git a/seaweed-block/docs/status-schema.md b/seaweed-block/docs/status-schema.md index 1e40cb8403..6f2a52d976 100644 --- a/seaweed-block/docs/status-schema.md +++ b/seaweed-block/docs/status-schema.md @@ -247,9 +247,11 @@ Durable store state of the served volume. Go type `volume.durableStatusBody`. | `Volumes[].Chunk.Maintenance.lastPass.plannedChunks` | int64 | chunk objects considered for removal | | `Volumes[].Chunk.Maintenance.lastPass.plannedRoots` | int64 | root objects considered for removal | | `Volumes[].Chunk.Maintenance.lastPass.plannedSegments` | int64 | segment objects considered for removal | +| `Volumes[].Chunk.Maintenance.lastPass.plannedLists` | int64 | immutable list pages considered for removal | | `Volumes[].Chunk.Maintenance.lastPass.removedChunks` | int64 | chunk objects removed | | `Volumes[].Chunk.Maintenance.lastPass.removedRoots` | int64 | root objects removed | | `Volumes[].Chunk.Maintenance.lastPass.removedSegments` | int64 | segment objects removed | +| `Volumes[].Chunk.Maintenance.lastPass.removedLists` | int64 | immutable list pages removed | | `Volumes[].Chunk.Maintenance.lastPass.error` | string | one-line callback error; empty when the callback completed | | `Volumes[].Chunk.Maintenance.lastPass.headGenError` | string | diagnostic HEAD read error; empty when read | | `Volumes[].Chunk.Maintenance.lastPass.headGen` | uint64 | observed cleaning HEAD generation; diagnostic only |