diff --git a/seaweed-block/.github/model-code-trace.tsv b/seaweed-block/.github/model-code-trace.tsv index 15a49d44f8..773b9877a7 100644 --- a/seaweed-block/.github/model-code-trace.tsv +++ b/seaweed-block/.github/model-code-trace.tsv @@ -206,3 +206,7 @@ core/frontend/chunkstore/layout/list_chain.go QueueCap.Produce core/frontend/chunkstore/layout/delete_intent.go QueueCap.Consume core/frontend/chunkstore/clean_intent_b.go QueueCap.Consume core/frontend/chunkstore/layout/commit.go QueueCap.TakeBack +core/frontend/chunkstore/layout/delete_intent.go VolDelSweep.Stage +core/frontend/chunkstore/layout/delete_intent.go VolDelSweep.Land +core/frontend/chunkstore/layout/list_chain.go VolDelSweep.Stage +core/frontend/chunkstore/layout/list_chain.go VolDelSweep.Land diff --git a/seaweed-block/core/frontend/chunkstore/catalog_b.go b/seaweed-block/core/frontend/chunkstore/catalog_b.go index 11310bb97a..e93efc235a 100644 --- a/seaweed-block/core/frontend/chunkstore/catalog_b.go +++ b/seaweed-block/core/frontend/chunkstore/catalog_b.go @@ -283,7 +283,7 @@ func rootRefs(ctx context.Context, r *layout.Reader, rn layout.RootName) ([]layo return out, err } -// listObjects lists the volume's pool, segment and root entries. +// listObjects lists the volume's pool, segment, root and immutable list entries. func (c *BCatalog) listObjects(ctx context.Context, v VolumeRef) ([]string, error) { dir := path.Join(c.base, v.Dir()) var out []string @@ -300,7 +300,7 @@ func (c *BCatalog) listObjects(ctx context.Context, v VolumeRef) ([]string, erro out = append(out, path.Join(layout.PoolDir, b, n)) } } - for _, sub := range []string{layout.SegDir, layout.RootDir} { + for _, sub := range []string{layout.SegDir, layout.RootDir, layout.ListDir} { names, err := c.listAll(ctx, path.Join(dir, sub)) if err != nil { return nil, err diff --git a/seaweed-block/core/frontend/chunkstore/catalog_delete_list_test.go b/seaweed-block/core/frontend/chunkstore/catalog_delete_list_test.go new file mode 100644 index 0000000000..aacc3c409b --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/catalog_delete_list_test.go @@ -0,0 +1,122 @@ +package chunkstore + +import ( + "bytes" + "context" + "errors" + "fmt" + "path" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +type volumeListDeleteProbe struct { + Filer + store *LayoutStore + fail bool + calls int +} + +func (f *volumeListDeleteProbe) DeleteEntry(ctx context.Context, dir, name string, expected map[string][]byte) error { + if path.Base(dir) == layout.ListDir { + h, found, err := f.store.ReadHead(ctx) + if err != nil || !found || h.State != layout.StateDeleting && h.State != layout.StateDeleted { + return fmt.Errorf("list page removed outside delete ordering: state=%s found=%v err=%v", h.State, found, err) + } + if string(expected[layoutVolume]) != f.store.id.String() { + return errors.New("list page delete omitted full volume identity") + } + f.calls++ + if f.fail { + f.fail = false + return errors.New("interrupted list page removal") + } + } + return f.Filer.DeleteEntry(ctx, dir, name, expected) +} + +// C7: a catalog delete must leave no list objects, including unfinished snapshot +// intent pages, and its rerun must also collect a late page in that incarnation. +func TestBCatalogVolumeDeleteRemovesIntentListPages(t *testing.T) { + for _, interrupt := range []bool{false, true} { + t.Run(fmt.Sprintf("interrupted=%t", interrupt), func(t *testing.T) { + ctx := context.Background() + c, v, s, orphans := pendingIntentCatalog(t) + dir := path.Join(c.base, v.Dir(), layout.ListDir) + names, err := c.listAll(ctx, dir) + if err != nil || len(names) != 2 { + t.Fatalf("intent fixture pages=%v err=%v", names, err) + } + lateRel := path.Join(layout.ListDir, names[0]) + lateRaw, found, err := s.Fetch(ctx, path.Join(s.root, lateRel)) + if err != nil || !found { + t.Fatalf("capture late page: %v %v", found, err) + } + // A different full identity under the same volume name is a keeper. + keeper := newRef(t, v.Name) + if _, err := c.CreateVolume(ctx, keeper, layout.Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4 * 4096}); err != nil { + t.Fatal(err) + } + ks, err := c.Store(keeper) + if err != nil { + t.Fatal(err) + } + page := layout.ListPage{VolumeID: keeper.ID, Kind: layout.ListDrop, Producer: "keeper", Generation: 1, Pages: 1, Entries: []string{orphans[0].Path()}} + raw, err := page.Encode() + if err != nil { + t.Fatal(err) + } + ref, err := page.Ref() + if err != nil { + t.Fatal(err) + } + keeperRel, err := ref.Path() + if err != nil { + t.Fatal(err) + } + if err := ks.Create(ctx, keeperRel, raw, "keeper"); err != nil { + t.Fatal(err) + } + probe := &volumeListDeleteProbe{Filer: c.f, store: s, fail: interrupt} + c.f = probe + _, err = c.DeleteVolume(ctx, v, okDeleteAuthority{}) + if interrupt { + if err == nil { + t.Fatal("list-removal interruption was ignored") + } + h, _, readErr := s.ReadHead(ctx) + if readErr != nil || h.State != layout.StateDeleting { + t.Fatalf("failed list removal marked deleted: %s %v", h.State, readErr) + } + _, err = c.DeleteVolume(ctx, v, okDeleteAuthority{}) + } + if err != nil { + t.Fatal(err) + } + if probe.calls < 2 { + t.Fatalf("no actual intent page removal: %d", probe.calls) + } + if names, err := c.listAll(ctx, dir); err != nil || len(names) != 0 { + t.Fatalf("C7 objects left after delete: %v err=%v", names, err) + } + h, _, err := s.ReadHead(ctx) + if err != nil || h.State != layout.StateDeleted { + t.Fatalf("final HEAD: %s %v", h.State, err) + } + if err := s.Create(ctx, lateRel, lateRaw, "late-dead-holder"); err != nil { + t.Fatal(err) + } + if _, err := c.DeleteVolume(ctx, v, okDeleteAuthority{}); err != nil { + t.Fatal(err) + } + if names, err := c.listAll(ctx, dir); err != nil || len(names) != 0 { + t.Fatalf("late list page escaped rerun: %v %v", names, err) + } + got, found, err := ks.Fetch(ctx, path.Join(ks.root, keeperRel)) + if err != nil || !found || !bytes.Equal(got, raw) { + t.Fatalf("same-name keeper changed: found=%v err=%v", found, err) + } + }) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/delete_sites_test.go b/seaweed-block/core/frontend/chunkstore/delete_sites_test.go index fad68c7d23..4f3203aab9 100644 --- a/seaweed-block/core/frontend/chunkstore/delete_sites_test.go +++ b/seaweed-block/core/frontend/chunkstore/delete_sites_test.go @@ -36,7 +36,7 @@ var deleteSites = map[string]string{ "core/frontend/chunkstore/swfs.go SWFS.DeleteEntry -> DeleteEntry": "the filer client itself", "cmd/sw-block/chunk_b.go chunkSnapshots -> VolumeDir": "prints a dependent's directory from HEAD's dependent record (its name and id); nothing is read or written there", "core/frontend/chunkstore/catalog_b.go VolumeRef.Dir -> VolumeDir": "a VolumeRef is the master's record (name, layout id) or a reference's owner name and id (foreignOwners)", - "core/frontend/chunkstore/layout_store.go LayoutStore.deleteObject -> DeleteEntry": "only canonical pool, segment or root files under the configured volume root; HEAD, VOLUME and directory paths refused (TestLayoutStoreDeleteNeverRemovesControlRecords)", + "core/frontend/chunkstore/layout_store.go LayoutStore.deleteObject -> DeleteEntry": "only canonical pool, segment, root or list-page files under the configured volume root; HEAD, VOLUME and directory paths refused (TestLayoutStoreDeleteNeverRemovesControlRecords)", "core/frontend/chunkstore/layout/read.go Reader.ReadRef -> VolumeDir": "a foreign chunk's directory from the reference's owner name and id", } diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete.go b/seaweed-block/core/frontend/chunkstore/layout/delete.go index 7ca718b567..21c4cd1c0d 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete.go @@ -164,7 +164,7 @@ type DeleteProgress struct { // any line holds a live lease, checked between the HEAD read and its // conditional update, or while a snapshot has dependents; no holder // transition, claim or removal applies from here), then this volume released from every source it depends on, -// then every object of its pool, segments and roots deleted, each +// then every object of its pool, segments, roots and immutable lists deleted, each // conditional on belonging to this volume (a late delete of this run never // removes the object of a volume created again under the name), then HEAD // deleted. A source left out keeps an extra dependent, which over-protects @@ -195,7 +195,7 @@ func DeleteVolume(ctx context.Context, st HeadStore, auth DeleteAuthority, id Vo } for _, rel := range objects { if !isObjectPath(rel) { - return fmt.Errorf("%w: %q is not a pool, segment or root object; HEAD, VOLUME and the directory stay", ErrMalformed, rel) + return fmt.Errorf("%w: %q is not a pool, segment, root or list object; HEAD, VOLUME and the directory stay", ErrMalformed, rel) } } report := func(p DeleteProgress) { @@ -290,10 +290,10 @@ func namesVolume(ctx context.Context, r *Reader, h Head, owner VolumeID) (bool, } // isObjectPath reports whether rel names a content-named object of the -// volume (a chunk, a segment or a root): the only entries a volume delete +// volume (a chunk, segment, root or immutable list page): the only entries a volume delete // removes. HEAD (which stays, deleted), VOLUME and the directory are not. func isObjectPath(rel string) bool { - for _, dir := range []string{PoolDir + "/", SegDir + "/", RootDir + "/"} { + for _, dir := range []string{PoolDir + "/", SegDir + "/", RootDir + "/", ListDir + "/"} { if strings.HasPrefix(rel, dir) && len(rel) > len(dir) && !strings.Contains(rel, "..") { return true } diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go b/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go index 8709867f4b..60781ae348 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go @@ -38,6 +38,8 @@ func StageSnapshotDeletePage(ctx context.Context, st ListChainStore, base uint64 if err != nil { return ListRef{}, err } + ctx, cancel := context.WithTimeout(ctx, ListStageRequestTimeout) + defer cancel() h, found, err := st.ReadHead(ctx) if err != nil { return ListRef{}, err @@ -81,38 +83,43 @@ func adoptDeleteIntentPage(ctx context.Context, st ListChainStore, volume Volume } writer := deleteIntentWriter(base, ref) for round := 0; round < maxEnsureRounds; round++ { - meta, found, err := st.Stat(ctx, rel) - if err != nil { - return err - } - if !found { - return ErrListPageMissing - } - if meta.Volume != volume { - return ErrIdentity - } - h, exists, err := st.ReadHead(ctx) - if err != nil { - return err - } - if !exists { - return ErrHeadAbsent - } - if h.VolumeID != volume { - return ErrIdentity - } - if err := deleteIntentWindow(h, base); err != nil { - return err - } - if meta.Session == writer && meta.Mark == "" { - return nil - } - err = st.Reuse(ctx, rel, meta, writer) + err := func() error { + ctx, cancel := context.WithTimeout(ctx, ListStageRequestTimeout) + defer cancel() + meta, found, err := st.Stat(ctx, rel) + if err != nil { + return err + } + if !found { + return ErrListPageMissing + } + if meta.Volume != volume { + return ErrIdentity + } + h, exists, err := st.ReadHead(ctx) + if err != nil { + return err + } + if !exists { + return ErrHeadAbsent + } + if h.VolumeID != volume { + return ErrIdentity + } + if err := deleteIntentWindow(h, base); err != nil { + return err + } + if meta.Session == writer && meta.Mark == "" { + return nil + } + return st.Reuse(ctx, rel, meta, writer) + }() if errors.Is(err, ErrPrecondition) { continue } return err } + return fmt.Errorf("%w: delete intent page kept moving during adoption", ErrPrecondition) } diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete_test.go b/seaweed-block/core/frontend/chunkstore/layout/delete_test.go index 1af28259c6..d03cc5be13 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete_test.go @@ -423,7 +423,7 @@ func (r *raceTarget) CreateDeletedHead(ctx context.Context, h Head, cause HeadWr // names HEAD (which stays, deleted), VOLUME or the directory is refused // before any object is deleted. func TestDeleteVolume_RemovesOnlyObjects(t *testing.T) { - for _, bad := range []string{HeadName, VolumeName, "", "pool/", "pool/../HEAD", "other/x"} { + for _, bad := range []string{HeadName, VolumeName, "", "pool/", "pool/../HEAD", "lists/", "lists/../HEAD", "other/x"} { w := newDeleteWorld() o := w.objects() if err := DeleteVolume(context.Background(), w.t, &fakeMaster{}, idFor("t"), []HeadStore{w.src}, o, fixed(append(append([]string(nil), w.rels...), bad))); !errors.Is(err, ErrMalformed) || len(o.writes) != 0 { diff --git a/seaweed-block/core/frontend/chunkstore/layout/list_chain.go b/seaweed-block/core/frontend/chunkstore/layout/list_chain.go index e090596a58..69aec39bdb 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/list_chain.go +++ b/seaweed-block/core/frontend/chunkstore/layout/list_chain.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "time" ) // ListCursor is HEAD's bounded continuation. Generation identifies the @@ -114,6 +115,11 @@ func listSession(h Head, me HolderID, session, kind string) error { return nil } +// ListStageRequestTimeout is VolDelSweep r3's RT: each staging attempt starts +// its own deadline before HEAD is read, including its subsequent object write. +// This bounds client waiting; it cannot cancel an already queued server apply. +const ListStageRequestTimeout = 30 * time.Second + // StageListPage writes a bounded page in the already-open snap session. // Ending the session during I/O may leave an orphan, but cannot authorize // its later publication: that CAS checks the original generation/session. @@ -121,6 +127,8 @@ func StageListPage(ctx context.Context, st ListChainStore, me HolderID, session if p.Kind == ListSnapshotDeleteIntent { return ListRef{}, fmt.Errorf("%w: use non-retagging snapshot-delete staging", ErrIdentity) } + ctx, cancel := context.WithTimeout(ctx, ListStageRequestTimeout) + defer cancel() h, found, err := st.ReadHead(ctx) if err != nil { return ListRef{}, err diff --git a/seaweed-block/core/frontend/chunkstore/layout/list_stage_deadline_test.go b/seaweed-block/core/frontend/chunkstore/layout/list_stage_deadline_test.go new file mode 100644 index 0000000000..a8a8638b66 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/layout/list_stage_deadline_test.go @@ -0,0 +1,265 @@ +package layout + +import ( + "context" + "errors" + "fmt" + "testing" + "testing/synctest" + "time" +) + +// VolDelSweep r3 pins RT at 30 s. These controls require a staging-owned deadline, +// established at HEAD check and unchanged through the actual write. +type stageDeadlineProbe struct { + *chainStore + parentDeadline time.Time + allowParentDeadline bool + headBudget time.Duration + checkedDeadline time.Time + writes int +} + +func (s *stageDeadlineProbe) ReadHead(ctx context.Context) (Head, bool, error) { + deadline, ok := ctx.Deadline() + if !ok || !deadline.Before(s.parentDeadline) && !(s.allowParentDeadline && deadline.Equal(s.parentDeadline)) { + return Head{}, false, errors.New("staging HEAD check has no request-owned RT deadline") + } + s.headBudget = time.Until(deadline) + s.checkedDeadline = deadline + return s.chainStore.ReadHead(ctx) +} + +func (s *stageDeadlineProbe) Stat(ctx context.Context, rel string) (ObjectMeta, bool, error) { + if !s.checkedDeadline.IsZero() { + // Consume part of the interval after HEAD check but before the write. + delay := time.Until(s.checkedDeadline) / 2 + timer := time.NewTimer(delay) + defer timer.Stop() + select { + case <-timer.C: + case <-ctx.Done(): + return ObjectMeta{}, false, ctx.Err() + } + } + return s.chainStore.Stat(ctx, rel) +} + +func (s *stageDeadlineProbe) waitWrite(ctx context.Context) error { + s.writes++ + deadline, ok := ctx.Deadline() + if !ok || !deadline.Equal(s.checkedDeadline) { + return fmt.Errorf("staging write renewed RT after its HEAD check: head=%v write=%v", s.checkedDeadline, deadline) + } + <-ctx.Done() + return ctx.Err() // A context-aware backend never applies the expired write. +} +func (s *stageDeadlineProbe) Create(ctx context.Context, _ string, _ []byte, _ string) error { + return s.waitWrite(ctx) +} +func (s *stageDeadlineProbe) Reuse(ctx context.Context, _ string, _ ObjectMeta, _ string) error { + return s.waitWrite(ctx) +} + +func TestListStagingWriteDeadlineStartsAtItsOwnHeadCheck(t *testing.T) { + for _, kind := range []string{"snapshot-create", "holder-create", "adopt-reuse"} { + t.Run(kind, func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + parent, cancel := context.WithTimeout(context.Background(), 24*time.Hour) + defer cancel() + parentDeadline, _ := parent.Deadline() + var st *chainStore + var p ListPage + if kind == "holder-create" { + st, _, p = chainFixture(t) + } else { + st, _, p = deleteIntentFixture(t) + } + ref, err := p.Ref() + if err != nil { + t.Fatal(err) + } + rel, _ := ref.Path() + if kind == "adopt-reuse" { + if _, err := StageSnapshotDeletePage(parent, st, st.h.Gen, p); err != nil { + t.Fatal(err) + } + } + probe := &stageDeadlineProbe{chainStore: st, parentDeadline: parentDeadline} + switch kind { + case "snapshot-create": + _, err = StageSnapshotDeletePage(parent, probe, st.h.Gen, p) + case "holder-create": + _, err = StageListPage(parent, probe, me, "s1", p) + case "adopt-reuse": + err = adoptDeleteIntentPage(parent, probe, st.volume, st.h.Gen, ref) + } + if !errors.Is(err, context.DeadlineExceeded) || probe.writes != 1 { + t.Fatalf("staging must expire from HEAD check, not parent/write start: writes=%d err=%v", probe.writes, err) + } + if probe.headBudget != 30*time.Second { + t.Fatalf("RT at HEAD check = %v, want 30s", probe.headBudget) + } + if parent.Err() != nil { + t.Fatal("staging used up the parent operation deadline") + } + if kind == "adopt-reuse" { + meta, _, err := st.Stat(parent, rel) + if err != nil || meta.Session != p.Producer { + t.Fatalf("expired reuse changed tags: %+v %v", meta, err) + } + } else if _, found, err := st.Stat(parent, rel); err != nil || found { + t.Fatalf("expired create landed: found=%v err=%v", found, err) + } + }) + }) + } +} + +func TestListStagingHonorsEarlierParentDeadline(t *testing.T) { + for _, kind := range []string{"snapshot-create", "holder-create", "adopt-reuse"} { + t.Run(kind, func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + parent, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + deadline, _ := parent.Deadline() + var st *chainStore + var p ListPage + if kind == "holder-create" { + st, _, p = chainFixture(t) + } else { + st, _, p = deleteIntentFixture(t) + } + ref, _ := p.Ref() + if kind == "adopt-reuse" { + if _, err := StageSnapshotDeletePage(parent, st, st.h.Gen, p); err != nil { + t.Fatal(err) + } + } + probe := &stageDeadlineProbe{chainStore: st, parentDeadline: deadline, allowParentDeadline: true} + var err error + switch kind { + case "snapshot-create": + _, err = StageSnapshotDeletePage(parent, probe, st.h.Gen, p) + case "holder-create": + _, err = StageListPage(parent, probe, me, "s1", p) + case "adopt-reuse": + err = adoptDeleteIntentPage(parent, probe, st.volume, st.h.Gen, ref) + } + if !errors.Is(err, context.DeadlineExceeded) || parent.Err() != context.DeadlineExceeded || probe.headBudget != 10*time.Second || probe.writes != 1 { + t.Fatalf("parent deadline changed: budget=%v writes=%d parent=%v err=%v", probe.headBudget, probe.writes, parent.Err(), err) + } + }) + }) + } +} + +type retryStageDeadlineStore struct { + *chainStore + checks int + writes int + deadlines []time.Time +} + +func (s *retryStageDeadlineStore) ReadHead(ctx context.Context) (Head, bool, error) { + deadline, ok := ctx.Deadline() + if !ok || time.Until(deadline) != 30*time.Second { + return Head{}, false, errors.New("retry did not acquire its own 30s check") + } + s.deadlines = append(s.deadlines, deadline) + s.checks++ + return s.chainStore.ReadHead(ctx) +} +func (s *retryStageDeadlineStore) Reuse(ctx context.Context, rel string, meta ObjectMeta, session string) error { + s.writes++ + if s.checks != s.writes { + return errors.New("retry wrote without a fresh HEAD check") + } + timer := time.NewTimer(20 * time.Second) + defer timer.Stop() + select { + case <-timer.C: + case <-ctx.Done(): + return ctx.Err() + } + if s.writes == 1 { + return ErrPrecondition + } + return s.chainStore.Reuse(ctx, rel, meta, session) +} +func TestListStagingAdoptionRetryGetsFreshCheckAndDeadline(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + ctx := context.Background() + st, ref, page := deleteIntentFixture(t) + if _, err := StageSnapshotDeletePage(ctx, st, st.h.Gen, page); err != nil { + t.Fatal(err) + } + probe := &retryStageDeadlineStore{chainStore: st} + started := time.Now() + if err := adoptDeleteIntentPage(ctx, probe, st.volume, st.h.Gen, ref.Ref); err != nil { + t.Fatal(err) + } + if probe.checks != 2 || probe.writes != 2 || time.Since(started) != 40*time.Second || !probe.deadlines[1].After(probe.deadlines[0]) { + t.Fatalf("retry shared an old check/deadline: checks=%d writes=%d elapsed=%v deadlines=%v", probe.checks, probe.writes, time.Since(started), probe.deadlines) + } + }) +} + +type stageStatDeadlineStore struct { + *chainStore + stats int + checks int +} + +func (s *stageStatDeadlineStore) Stat(ctx context.Context, _ string) (ObjectMeta, bool, error) { + s.stats++ + d, ok := ctx.Deadline() + if !ok || time.Until(d) > 30*time.Second { + return ObjectMeta{}, false, errors.New("staging Stat lacks the attempt's RT deadline") + } + <-ctx.Done() + return ObjectMeta{}, false, ctx.Err() +} +func (s *stageStatDeadlineStore) ReadHead(ctx context.Context) (Head, bool, error) { + s.checks++ + return s.chainStore.ReadHead(ctx) +} +func TestListStagingBoundsStatBeforeAnyWrite(t *testing.T) { + for _, kind := range []string{"snapshot-create", "holder-create", "adopt-reuse"} { + t.Run(kind, func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + var st *chainStore + var p ListPage + if kind == "holder-create" { + st, _, p = chainFixture(t) + } else { + st, _, p = deleteIntentFixture(t) + } + ref, _ := p.Ref() + if kind == "adopt-reuse" { + if _, err := StageSnapshotDeletePage(context.Background(), st, st.h.Gen, p); err != nil { + t.Fatal(err) + } + } + probe := &stageStatDeadlineStore{chainStore: st} + started := time.Now() + var err error + switch kind { + case "snapshot-create": + _, err = StageSnapshotDeletePage(context.Background(), probe, st.h.Gen, p) + case "holder-create": + _, err = StageListPage(context.Background(), probe, me, "s1", p) + case "adopt-reuse": + err = adoptDeleteIntentPage(context.Background(), probe, st.volume, st.h.Gen, ref) + } + wantChecks := 1 + if kind == "adopt-reuse" { + wantChecks = 0 + } + if !errors.Is(err, context.DeadlineExceeded) || time.Since(started) != 30*time.Second || probe.stats != 1 || probe.checks != wantChecks { + t.Fatalf("Stat exceeded attempt: elapsed=%v stats=%d checks=%d err=%v", time.Since(started), probe.stats, probe.checks, err) + } + }) + }) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/layout/verify.go b/seaweed-block/core/frontend/chunkstore/layout/verify.go index c80eb9dbc4..a9fe0f31b9 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/verify.go +++ b/seaweed-block/core/frontend/chunkstore/layout/verify.go @@ -13,7 +13,8 @@ import ( // segments and the chunks they name. It never writes or deletes. With // Orphans it also lists the volume's own pool, seg and root names that no // reachable root names (removal 7' deletes those inside the lease; Verify -// only reports them). +// only reports them). For a deleted volume it also reports leftover lists/ +// pages; live or deleting volumes can still have pending list work. // Verify depths. const ( @@ -442,6 +443,23 @@ func (v *verifier) orphans(ctx context.Context, h Head) error { return nil } var found []Finding + // A deleted incarnation has no remaining list consumer. Do not infer + // reachability for list pages of a live/deleting volume: pending work and + // in-flight staging can legitimately keep them outside a root graph. + if h.State == StateDeleted { + names, err := v.opts.List(ctx, path.Join(v.base, v.vol, ListDir)) + if err != nil { + return fmt.Errorf("layout: list %s: %w", path.Join(v.vol, ListDir), err) + } + for _, n := range names { + rel, err := (ListRef{Hash: n, Pages: 1}).Path() + if err != nil { + found = append(found, Finding{FindMalformed, path.Join(v.vol, ListDir, n), err.Error()}) + } else { + found = append(found, Finding{FindOrphan, path.Join(v.vol, rel), "list page remains in a deleted volume directory; report only"}) + } + } + } for _, dir := range []string{RootDir, SegDir} { names, err := v.opts.List(ctx, path.Join(v.base, v.vol, dir)) if err != nil { diff --git a/seaweed-block/core/frontend/chunkstore/verify_deleted_lists_test.go b/seaweed-block/core/frontend/chunkstore/verify_deleted_lists_test.go new file mode 100644 index 0000000000..4f176e4ce0 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/verify_deleted_lists_test.go @@ -0,0 +1,144 @@ +package chunkstore + +import ( + "context" + "path" + "strings" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +// Old deletes left list pages behind. Only a confirmed deleted incarnation +// makes those names reportable; active/pending work is not inferred orphaned. +func TestVerifyReportsDeletedVolumeListPagesWithoutMutation(t *testing.T) { + for _, state := range []string{layout.StateLive, layout.StateDeleting, layout.StateDeleted} { + for _, orphans := range []bool{false, true} { + t.Run(state+"/orphans="+map[bool]string{true: "yes", false: "no"}[orphans], func(t *testing.T) { + fb, id := verifyFixtureVolume(t) + dir := layout.VolumeDir("v", id) + hp := path.Join("/blocks", dir, layout.HeadName) + h, err := layout.DecodeHead(fb.fakeFiler.entries[hp].Content, 1, id) + if err != nil { + t.Fatal(err) + } + h.State = state + raw, err := h.Encode() + if err != nil { + t.Fatal(err) + } + fb.fakeFiler.entries[hp].Content = raw + hash := strings.Repeat("a", 64) + rel := path.Join(dir, layout.ListDir, hash) + putFile(t, fb.fakeFiler, path.Join("/blocks", rel), []byte("old list page")) + // Another full identity under the same name is outside this pass. + other, err := layout.NewVolumeID() + if err != nil { + t.Fatal(err) + } + putFile(t, fb.fakeFiler, path.Join("/blocks", layout.VolumeDir("v", other), layout.ListDir, hash), []byte("keeper")) + before := snapshotStore(fb) + r, err := VerifyLayout(context.Background(), fb, "/blocks", dir, layout.VerifyOptions{Orphans: orphans}) + if err != nil || !r.Complete { + t.Fatalf("verify: %+v %v", r, err) + } + want := 0 + if state == layout.StateDeleted && orphans { + want = 1 + } + if len(r.Findings) != want { + t.Fatalf("findings=%+v want %d", r.Findings, want) + } + if want == 1 && (r.Findings[0].Class != layout.FindOrphan || r.Findings[0].Path != rel) { + t.Fatalf("wrong report: %+v", r.Findings) + } + if snapshotStore(fb) != before { + t.Fatal("report changed filer entries or blobs") + } + }) + } + } +} + +func TestVerifyDeletedListPagesRequireStableHead(t *testing.T) { + for _, mode := range []string{"stable", "advance", "absent", "error", "unknown", "initial-unknown"} { + t.Run(mode, func(t *testing.T) { + fb, id := verifyFixtureVolume(t) + dir := layout.VolumeDir("v", id) + hp := path.Join("/blocks", dir, layout.HeadName) + h, err := layout.DecodeHead(fb.fakeFiler.entries[hp].Content, 1, id) + if err != nil { + t.Fatal(err) + } + h.State = layout.StateDeleted + raw, err := h.Encode() + if err != nil { + t.Fatal(err) + } + fb.fakeFiler.entries[hp].Content = raw + putFile(t, fb.fakeFiler, path.Join("/blocks", dir, layout.ListDir, strings.Repeat("a", 64)), []byte("leftover")) + f := &verifyChangingHead{filerBlobs: fb, mode: mode} + r, err := VerifyLayout(context.Background(), f, "/blocks", dir, layout.VerifyOptions{Orphans: true}) + if err != nil { + t.Fatal(err) + } + if mode == "stable" { + if !r.Complete || !r.OrphansChecked || len(r.Findings) != 1 || r.Findings[0].Class != layout.FindOrphan { + t.Fatalf("stable report: %+v", r) + } + } else if r.Complete || r.OrphansChecked || len(r.Findings) != 0 { + t.Fatalf("unstable report: %+v", r) + } + }) + } +} + +// Recreate the actual v1.1 residue: valid intent pages left in a directory +// whose volume-delete has finished, including the now-absent root objects. +func TestVerifyReportsListResidueAfterCatalogDelete(t *testing.T) { + ctx := context.Background() + c, v, st, _ := pendingIntentCatalog(t) + names, err := c.listAll(ctx, path.Join(st.root, layout.ListDir)) + if err != nil || len(names) != 2 { + t.Fatalf("pages=%v err=%v", names, err) + } + pages := map[string][]byte{} + for _, n := range names { + raw, found, err := st.Fetch(ctx, path.Join(st.root, layout.ListDir, n)) + if err != nil || !found { + t.Fatalf("capture page: %v %v", found, err) + } + pages[n] = raw + } + if _, err := c.DeleteVolume(ctx, v, okDeleteAuthority{}); err != nil { + t.Fatal(err) + } + for n, raw := range pages { + if err := st.Create(ctx, path.Join(layout.ListDir, n), raw, "legacy-leftover"); err != nil { + t.Fatal(err) + } + } + backend := struct { + Filer + Blobs + }{c.f, c.b} + r, err := VerifyLayout(ctx, backend, c.base, v.Dir(), layout.VerifyOptions{Orphans: true, ExpectedID: v.ID}) + if err != nil || !r.Complete || !r.OrphansChecked || !r.MasterIdentityChecked { + t.Fatalf("verify deleted: %+v %v", r, err) + } + reported := map[string]bool{} + for _, f := range r.Findings { + if f.Class == layout.FindOrphan && strings.HasPrefix(f.Path, path.Join(v.Dir(), layout.ListDir)+"/") { + reported[path.Base(f.Path)] = true + } + } + if len(reported) != len(pages) { + t.Fatalf("pages not reported: %+v", r) + } + for n, raw := range pages { + got, found, err := st.Fetch(ctx, path.Join(st.root, layout.ListDir, n)) + if err != nil || !found || string(got) != string(raw) { + t.Fatalf("report changed page %s: %v %v", n, found, err) + } + } +} diff --git a/seaweed-block/docs/design/immutable-list-pages.md b/seaweed-block/docs/design/immutable-list-pages.md index 33ccb78897..4add62b143 100644 --- a/seaweed-block/docs/design/immutable-list-pages.md +++ b/seaweed-block/docs/design/immutable-list-pages.md @@ -246,3 +246,15 @@ are 114452, 1119764, 1119764 and 1119764. Root bytes remain the separate size-dependent term: 126, 225, 2700 and 10422. The by-change segment index and two-level root are deferred; these measurements do not remove the compatibility full sweep's namespace cost. + + +### Staging request bound + +Each staging attempt starts a 30 s deadline before its HEAD read and passes it +through the object write; an earlier caller deadline wins. This covers snapshot +intent creation, generic list-page staging, and adoption's Stat, HEAD check and +conditional Reuse. A new adoption attempt gets a fresh check and deadline; +EnsureObject retries within an attempt do not renew that attempt's deadline. +The bound limits client waiting, not a queued server apply. A volume-delete +rerun collects a late page; durable scheduled resweep and its window starting +at the deleting mark remain separate work. diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 5dc80a3e43..f6d5d87d95 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -1216,7 +1216,7 @@ Notes: | `INV-VERIFY-NOTFOUND-001` | Verify reports `MISSING` only when the store answers that the object does not exist; any other read failure ends the pass as incomplete with that error, and is never a finding. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyReadErrorIsReturned`, `TestVerifyFindsMissingAndCorrupt` (`core/frontend/chunkstore/layout/verify_test.go`); `TestOpsChunk_VerifyReadErrorIsIncomplete` (`cmd/sw-block/chunk_verify_test.go`) | — | ACTIVE | | `INV-VERIFY-REACH-001` | A complete pass checks every object the current root and every snapshot root name (roots, segments, chunks): an absent one is `MISSING`; one whose bytes do not hash to its name, at depth full, is `CORRUPT`. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyCleanVolume`, `TestVerifyFindsMissingAndCorrupt`, `TestVerifyWalksSnapshotRoots` (`core/frontend/chunkstore/layout/verify_test.go`) | — | ACTIVE | | `INV-VERIFY-INCOMPLETE-001` | A volume whose VOLUME or HEAD is absent or does not decode is never reported clean: the pass is incomplete and says which object. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyHeadMissingOrMalformedIsIncomplete` (`core/frontend/chunkstore/layout/verify_test.go`) | — | ACTIVE | -| `INV-VERIFY-ORPHAN-001` | With orphans on, only this volume's own full-id names that no root or live restore target names are ORPHAN. Owner/target paths use VolumeDir(name,id); an unreadable live target suppresses orphan findings. Verify deletes nothing. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyOrphans`, `TestVerifyDependentReachIsNotOrphanAndUnreadableDependentSuppresses` (`core/frontend/chunkstore/layout/verify_test.go`) ; `TestVerifyProductionLayoutCurrentAndRestored` (`core/frontend/chunkstore/verify_production_layout_test.go`) | — | ACTIVE | +| `INV-VERIFY-ORPHAN-001` | With orphans on, unreachable own full-id names are ORPHAN; a deleted volume's leftover list pages are also reported. Live/deleting list work is not judged orphaned. Unreadable live targets suppress orphan findings. Verify deletes nothing. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyReportsDeletedVolumeListPagesWithoutMutation`, `TestVerifyDeletedListPagesRequireStableHead`, `TestVerifyReportsListResidueAfterCatalogDelete`; `TestVerifyOrphans`, `TestVerifyDependentReachIsNotOrphanAndUnreadableDependentSuppresses` (`core/frontend/chunkstore/layout/verify_test.go`) ; `TestVerifyProductionLayoutCurrentAndRestored` (`core/frontend/chunkstore/verify_production_layout_test.go`) | — | ACTIVE | | `INV-VERIFY-IDENTITY-001` | Verify reads canonical VolumeDir(name,id) directories. VOLUME must match its directory, HEAD must match VOLUME, and a master-resolved id must match in full. A mismatched chunk-owner VOLUME is IDENTITY, never clean. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyVolumeRecordAndHeadID`, `TestVerifyChunkOwnerIdentity` (`core/frontend/chunkstore/layout/verify_test.go`), `TestVerifyDeduplicationNeverSkipsFullOwnerIdentity` (`core/frontend/chunkstore/verify_bindings_stat_test.go`) ; `TestVerifyProductionLayoutCurrentAndRestored` (`core/frontend/chunkstore/verify_production_layout_test.go`); `TestOpsChunk_VerifyProductionLayoutNameAndDirectory`, `TestOpsChunk_VerifyBindsMasterFullIDDespiteDirectoryPrefixCollision` (`cmd/sw-block/chunk_verify_production_test.go`) | — | ACTIVE | | `INV-RESTORE-HYDRATE-001` | The background hydrate walker fetches a chunk only through that chunk's shared fill flight: at most one fetch per chunk absence, and a fetched block is never installed over a block written locally. | M4 Holder (background hydrate) | `core/storage/chunk_hydrate_all.go` `HydrateAll`, `HydrateAllAt`, `startWalkerFill`, `nextHydrateTarget`, `admitFill`; `core/storage/chunk_hydration.go` `hydrationFlightLocked`; `core/storage/chunk_layer.go` `fillOnce` | `TestHydrateAll_FillsEveryChunkOnceAndReadsTheHeadImage`, `TestHydrateAll_YieldsToGuestReadsAndNeverFetchesTwice`, `TestHydrateAll_NeverOverwritesALocalWrite`, `TestHydrateAll_AdmitsEachFillThroughTheLimiterWithTheCallersClass`, `TestHydrateAll_RealBackgroundFillLimiterAdmitsEveryFill`, `TestHydrateAll_PermitIsHeldUntilTheOwnedFetchSettles`, `TestHydrateAll_RevocationStopsTheWalker`, `TestHydrateAll_CancelReturnsWhileTheFetchIsHeld`, `TestHydrateAll_PacedByByteRate` (`core/storage/chunk_hydrate_all_test.go`) | — | DORMANT | | `INV-RESTORE-OWN-BATCH-001` | A batch cut re-uploads at most N local chunks whose HEAD keys name another volume under new own keys, even when their bytes equal HEAD's, in one ordinary cut (one intent, one HEAD CAS); it never fetches an absent chunk. | M6.Restore.Owning>Owning | `core/storage/chunk_own.go` `OwnBatch`; `core/storage/chunk_cut_payload.go` `streamCutPayloads` | `TestOwnBatch_BoundedBatchesReplaceEveryForeignKey`, `TestOwnBatch_SkipsChunksNotLocal`, `TestOwnBatch_CarriesGuestWrites` (`core/storage/chunk_own_test.go`) | `RestoreIndependence` `NoGap` | DORMANT | @@ -1356,8 +1356,8 @@ Notes: | `INV-SNAPK-REF-ID-001` | Every chunk reference in a segment carries its owner's volume id; a read checks it against the owner's VOLUME before fetching (another id is ErrIdentity), and the remover tells its own chunks by its VOLUME id. | Content-named layout | `core/frontend/chunkstore/layout` `layout.go` `Segment.Encode`; `read.go` `Image.Chunk`; `remove.go` | `TestSegment_EncodeRefusals`, `TestRead_ForeignChunkNeedsTheOwnersVolumeID`, `TestRemoveUnreachable_NeedsItsOwnVolumeID` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-DEP-ID-001` | Every dependent records the target's volume id and the root of the snapshot it depends on; a dependent without the id, or of another root, is refused. | M9 snapshots and dependents | `core/frontend/chunkstore/layout` `head.go` `Head.check` | `TestHead_Refusals`, `TestHead_GoldenEncodingRoundTrip` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-CLAIM-ID-001` | A holder is its epoch, its server and the claim id its claim wrote into HEAD; every transition refuses the same server at the same epoch with another claim id. | M9 every transition | `core/frontend/chunkstore/layout` `head.go` `heldBy`; `claim.go` `Head.Claim` | `TestClaim_WritesItsClaimID`, `TestTransitions_RefuseAStaleHolder`, `TestHolderFunctions_RefuseAStaleHolder` | — (the snapshot kernel model is not in this repository) | ACTIVE | -| `INV-SNAPK-DELETE-ORDER-001` | A volume delete runs in its order, each prefix safe and the whole re-runnable: HEAD deleting, this volume released from every source, its objects deleted, HEAD deleted. | M9 idle → deleting → deleted | `core/frontend/chunkstore/layout` `delete.go` `DeleteVolume`; `core/frontend/chunkstore/catalog_b.go` `BCatalog.DeleteVolume`, `foreignOwners` | `TestDeleteVolume`, `TestDeleteVolume_InterruptAtEveryStep`, `TestRunMarkDeleting_InterruptAtEveryStep`, `TestRunMarkDeleted_InterruptAtEveryStep`; `TestBCatalog_DeleteRerunOnADeletedVolumeSucceeds`, `TestBCatalog_DeleteInterruptedAtEachStepCompletesOnRerun`, `TestBCatalog_DeleteRerunSkipsOnlyMissingRootsOfADeletingVolume` (`core/frontend/chunkstore/catalog_delete_rerun_test.go`); also in `core/frontend/chunkstore/layout/delete_test.go` | — (the snapshot kernel model is not in this repository) | ACTIVE | -| `INV-SNAPK-DELETE-OWNED-001` | Every object entry carries the id of its volume; a volume delete removes an object only if it carries that id, so a late delete of a finished run never removes the object of a volume created again under the name. | M9 deleting → deleted | `core/frontend/chunkstore/layout` `delete.go` `DeleteVolume`; `objects.go` `ObjectStore.DeleteOfVolume` | `TestDeleteVolume_ALateDeleteSparesTheNameReused`, `TestDeleteVolume` | — (the snapshot kernel model is not in this repository) | ACTIVE | +| `INV-SNAPK-DELETE-ORDER-001` | A volume delete runs in its order, each prefix safe and the whole re-runnable: HEAD deleting, this volume released from every source, its objects deleted, HEAD deleted. | M9 idle → deleting → deleted | `core/frontend/chunkstore/layout` `delete.go` `DeleteVolume`; `core/frontend/chunkstore/catalog_b.go` `BCatalog.DeleteVolume`, `foreignOwners` | `TestBCatalogVolumeDeleteRemovesIntentListPages` (including interrupted and late-page rerun); `TestDeleteVolume`, `TestDeleteVolume_InterruptAtEveryStep`, `TestRunMarkDeleting_InterruptAtEveryStep`, `TestRunMarkDeleted_InterruptAtEveryStep`; `TestBCatalog_DeleteRerunOnADeletedVolumeSucceeds`, `TestBCatalog_DeleteInterruptedAtEachStepCompletesOnRerun`, `TestBCatalog_DeleteRerunSkipsOnlyMissingRootsOfADeletingVolume` (`core/frontend/chunkstore/catalog_delete_rerun_test.go`); also in `core/frontend/chunkstore/layout/delete_test.go` | — (the snapshot kernel model is not in this repository) | ACTIVE | +| `INV-SNAPK-DELETE-OWNED-001` | Every object entry carries the id of its volume; a volume delete removes an object only if it carries that id, so a late delete of a finished run never removes the object of a volume created again under the name. | M9 deleting → deleted | `core/frontend/chunkstore/layout` `delete.go` `DeleteVolume`; `objects.go` `ObjectStore.DeleteOfVolume` | `TestBCatalogVolumeDeleteRemovesIntentListPages` (same-name keeper); `TestDeleteVolume_ALateDeleteSparesTheNameReused`, `TestDeleteVolume` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-DELETE-GATE-001` | HEAD becomes deleting only with a committed deletion reservation, no live lease (unclaimed grants included), no open activity and no snapshot with dependents; from deleting on, no holder transition, claim or removal applies. | M2 any → DeleteReserved; M9 idle → deleting | `core/frontend/chunkstore/layout` `delete.go` `Head.MarkDeleting`; `head.go` `holderErr`; `core/authority/workspace_delete_reservation.go`; `core/host/master/volume_delete_authority.go` `ReserveVolumeDeletion`, `CheckVolumeNoLiveLease`; `cmd/sw-block/chunk_volume_delete.go` `masterAuthority` | `TestMarkDeleting_Closure`, `TestMarkDeleted_Closure`, `TestDeleting_RefusesEveryHolderStep`, `TestDeleteVolume`; `TestCommittedDeleteStopsGrantsAndWaitsForTheWholeLease`, `TestDeleteReservationClosesPausedGrantWriters`, `TestDeleteReservationMustBeDurableBeforeItCanProveNoLease`, `TestDeleteReservationContextAndPersistenceFailuresStayUnknown`, `TestDeleteOfALiveVolumeIsRefusedBeforePersisting`, `TestDeleteReservationReplayAndRestart`, `TestDeletionReservationGuardSites` (`core/authority`); `TestVolumeDeleteAuthorityReservationSurvivesRestart`, `TestVolumeDeleteAuthorityRPCs` (`core/host/master`; durable RPC/restart probes run on Linux); `TestOpsChunkVolumeDeleteRequiresTheMastersLeaseProof`, `TestOpsChunkVolumeDeleteClosesAPausedFirstGrant`, `TestChunkVolumeDeleteAuthorityRPCSites` (`cmd/sw-block`) | The reservation makes no-live-lease stable; a claim racing the conditional HEAD update still fails its generation check. The snapshot kernel model is external; composed model review pending. | ACTIVE | | `INV-WS-DELETE-WITHOUT-ACK-001` | A delete without the holder's acknowledgement is admitted only while the master's record still awaits a replica store (stage 1), marked durably first; the mark freezes the wait, so the primary never serves. Past stage 1 the live-lease refusal stays. | M2 any authority line, stores still awaited → DeleteReserved without the holder's acknowledgement | `core/host/master/volume_delete_authority.go` `Reserve`; `core/host/master/store_attestation.go` `markDeleteWithoutAck`, `awaited` | `TestANeverCreatedVolumeIsDeletedWithoutItsHolder`, `TestAnEstablishedVolumeIsNotDeletedUnderALiveLease` (`core/host/master/workspace_delete_never_created_test.go`); `TestAStage2VolumeKeepsTheLiveLeaseRefusal`, `TestTheDeleteMarkFreezesTheStoreWait`, `TestAStage2VolumeIsNotMarkedForADeleteWithoutAck` (`core/host/master/workspace_delete_proof_test.go`); `TestDeleteMarkWriterCensus`, `TestDeleteMarkWriterCensusControls` (`core/host/master/store_attestation_census_test.go`) | CreateEvid2 model rows `mut_delete_on_flag_only`, `mut_no_horizon` | ACTIVE | | `INV-CLI-DELETE-PROGRESS-001` | Volume deletion bounds each sweep, continues across transient filer failures while objects are removed, reports on stderr while a sweep makes no progress (how long, the object it waits on, the count), and returns a retryable unavailable answer with progress after a no-progress window. | M9 deleting → deleted | `cmd/sw-block/chunk_volume_delete.go` `deleteVolumeWithProgress` | `TestVolumeDeleteContinuesAcrossTransientObjectFailures`, `TestVolumeDeleteReportsAStalledStoreWhileItWaits` (`cmd/sw-block/chunk_volume_delete_progress_test.go`) | Existing ordered delete; no new persisted state. | ACTIVE | @@ -1392,6 +1392,7 @@ Notes: | `INV-SNAP-DELETE-EXECUTOR-001` | A catalog delete attempt reads its issued handle before work, takes ownership by receipt CAS, and persists uncertain work as stalled. It never infers terminal success from a callback return; terminal replay reads the same incarnation. | M9 delete attempt transport | `BCatalog.RunSnapshotDeleteOperation`; CLI execution seam | `TestSnapshotDeleteCatalogResumesDurableIntentOnAnotherExecutor`, `TestSnapshotDeleteCatalogRefusesWrongIntentBeforeWork`, `TestSnapshotDeleteCatalogCannotInferSuccessFromWorkReturn`, `TestSnapshotDeleteOfflineCLILeavesProgressInFiler` | SnapDelete retained target; SnapOps owner/state refinement; V8 completion adapter and public command activation owed | STUB | | `INV-SNAP-OP-ADMISSION-CLOSE-001` | Admission checks HEAD after receipt publication and refuses a deleting/deleted or absent volume. Closed incarnations cannot answer retained operation queries; their terminal receipt bytes are not rewritten by closing. | M9 admission and observation | `checkSnapshotOperationAdmission`, `readOperationIndex`, create/delete admission | `TestSnapshotOperationAdmissionRechecksHeadAfterPublication`, `TestSnapshotOperationClosedVolumeRefusesReceipts`, `TestSnapshotOperationTerminalReadmissionRechecksHeadAfterFlag` | SnapVolDel rows 257-260 (per-incarnation) | STUB | | `INV-SNAP-OP-END-001` | Operation metadata is scoped to full VolumeID and creation generation. Late writes in a closed incarnation grant no authority. Dead-incarnation GC is idempotent and cannot affect a replacement; it does not promise no later writes. | M9 live incarnation to dead and GC | `operationDirectory`, `readOperationIndex`, `deleteSnapshotOperations` | `TestSnapshotOperationDeleteFencesPausedPublications`, `TestSnapshotOperationVolumeDeleteCleanupReruns`, `TestSnapshotOperationVolumeDeleteSparesForeignReceipt`, `TestSnapshotOperationDeadGCSparesUnobservedIncarnation` | SnapVolDel rows 257-260 (per-incarnation) | STUB | +| `INV-LIST-STAGE-RT-001` | Each list staging attempt gives its Stat, HEAD check and object write one 30 s deadline established before reading HEAD. An earlier caller deadline wins; a renewed attempt requires a fresh HEAD check. | VolDelSweep r3 Stage / Land, RT = 30 s | `layout/list_chain.go` `StageListPage`; `layout/delete_intent.go` `StageSnapshotDeletePage`, `adoptDeleteIntentPage` | `TestListStagingWriteDeadlineStartsAtItsOwnHeadCheck`, `TestListStagingHonorsEarlierParentDeadline`, `TestListStagingAdoptionRetryGetsFreshCheckAndDeadline`, `TestListStagingBoundsStatBeforeAnyWrite` | Client waiting only: an already queued server apply may still land late; delete rerun collects it. VolDelSweep r3 11/11 on az1 per model owner. Native controls pass; Linux qualification pending. | STUB | | `INV-SNAP-OP-CRASH-001` | A durable snapshot intent survives holder SIGKILL before publication and completes once after restart; after publication, restart settles its original receipt without another cut. | M9 operation recovery (planned) | Process-owned create executor; native crash qualification pending | `TestSnapshotOperationIntentAndPublicationCrashBoundaries`, `TestSnapshotOperationKillReceiptRejectsOrdinaryExit` (`cmd/blockvolume/snapshot_operation_crash_integration_test.go`) | SnapOps.Start/Publish/Settle; rows 211–219 (native red receipt owed) | STUB | | `INV-SNAPK-RETAIN-META-001` | Reachability, removal and the volume delete never read a snapshot's retention facts (source guard); the policy entry beside VOLUME changes by one conditional update and is read only by retain. | M9 snap → idle | `core/frontend/chunkstore/layout` `head.go` `SnapshotMeta`; `core/frontend/chunkstore` `retain_b.go` | `TestSnapshotMeta_WrittenOnceByTheCommit`, `TestGuard_SafetyIgnoresSnapshotMeta`, `TestBCatalog_RetainKeepsTheOldBehaviour`, `TestBCatalog_RetentionPolicyIsConditional` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-HEAD-BOUND-001` | HEAD stays inline: at most 10 snapshots, names at most 64 bytes, 4 labels, 4 dependents per snapshot and 16 per HEAD, refused where they enter with the cure; Encode refuses a HEAD above 64 KiB. A snapshot past 10 is refused before its cut: nothing is written. | M9 every transition | `core/frontend/chunkstore/layout` `head.go` `check`, `Encode`; `snapshots.go` `AddDependent`; `commit.go` `Commit`; `core/frontend/durable/provider_layout_snapshot.go` `SnapshotVolume`; `core/host/volume/chunk_control.go` `chunkErrorCode`; `core/host/volume/chunk_scheduled_snapshot.go` `ScheduledSnapshot` | `TestHead_SizeAtTheSnapshotCap`, `TestHead_BoundsRefused`, `TestChunkSnapshotPastTheLimitIsRefusedWithHEADUnchanged`, `TestScheduledSnapshotAtTheLimitStillPublishes`, `TestChunkSnapshotRefusalsAreTyped`, `TestLayoutProviderSnapshotVolume` | — (the snapshot kernel model is not in this repository) | ACTIVE | diff --git a/seaweed-block/docs/releases/verify-production-layout.md b/seaweed-block/docs/releases/verify-production-layout.md index 64da02b298..1b56f9e171 100644 --- a/seaweed-block/docs/releases/verify-production-layout.md +++ b/seaweed-block/docs/releases/verify-production-layout.md @@ -1,3 +1,43 @@ # Read-only verification on the production layout For v1.0.1, this replaces v1.0.0's warning not to use `ops chunk verify` on the production layout. Resolve a logical name with `--master MASTER --volume NAME`, or inspect an explicit `-` directory without the master. The full owner identity selects each referenced store, including borrowed restore chunks. `MasterIdentityChecked` discloses whether the full identity was compared with the master. With `--master`, an unresolved logical name leaves verification incomplete and exits 1. Without `--master`, an offline directory with no VOLUME record is a usage error and exits 2 without a missing-object finding. Uncertain dependent records suppress orphan conclusions. Verification remains read-only, including when it reports findings. + + +## List pages left by a v1.1 volume delete + +v1.1 omitted `lists/` pages when deleting a volume. In v1.1.1, +`ops chunk verify --orphans` reports these names as `ORPHAN` only when the +same directory's authenticated HEAD says `deleted` and its generation is stable +through the final confirmation. Live or deleting volumes may have pending list +work and are not reported by this check. A listing/confirmation failure is not +permission to remove anything. The report reads names, not page payloads, and +never deletes objects. Exit 3 means findings, not automatic repair. + +Inspect the exact old directory, rather than a logical name that may now name +a replacement: + +```text +sw-block ops chunk verify --chunk-filer FILER --chunk-path /blocks --volume NAME-ID8 --orphans +``` + +For manual cleanup, first retain the report and the old directory's VOLUME and +HEAD records. Check the full VOLUME ID against the deleted volume's recorded ID, +the canonical `NAME-ID8` directory, and HEAD's `deleted` state. Ensure that no +holder or operator is still writing this incarnation. If any identity or state +is uncertain, leave the objects and investigate. A replacement with the same +logical name has a different full ID and must be left intact. + +Using an administrator's `weed shell` connected to the same filer, remove only +the individual `lists/` leaf paths printed in that complete, stable report: + +```text +fs.rm /blocks/NAME-ID8/lists/EXACT_REPORTED_HASH +``` + +Substitute the configured base and the exact reported directory/hash; repeat +for each reported page. Do not use recursion, a wildcard, or a logical-name +prefix. Do not remove HEAD, VOLUME, pool, root or segment objects as part of this +procedure. Run the same read-only verification again and retain its output. +Previously deleted roots can also appear as `MISSING`; this procedure authorizes +only the reported list-page leaves. A page landing later is reported on the next +scan; this cleanup makes no terminal-write-fence or scheduled-resweep promise.