From 4a744372586a576781fed838471ee06f6ccd0bc0 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 13:35:55 -0800 Subject: [PATCH 1/6] chunkstore: test an operator snapshot delete during an open cleaning The cleaning has taken its HEAD view when the operator deletes a snapshot: one HEAD update by nobody's lease that leaves the clean activity open. The pass keeps every chunk its view named, never marks a chunk a root still names (K6 checked at every mark), and ends; the next pass removes the chunk only the deleted snapshot named. Co-Authored-By: Claude Opus 5.5 --- .../chunkstore/clean_opdelete_test.go | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go diff --git a/seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go b/seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go new file mode 100644 index 0000000000..9cf1334770 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go @@ -0,0 +1,168 @@ +package chunkstore + +import ( + "bytes" + "context" + "fmt" + "path" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +// markHookFiler runs hook before every MARK of a pool object (the removal's +// first write), with the object's name. +type markHookFiler struct { + *MemFiler + hook func(ctx context.Context, name string) error +} + +func (f *markHookFiler) UpdateEntry(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte) error { + if f.hook != nil && string(e.Extended[layoutKind]) == "object" && len(e.Extended[layoutMark]) > 0 { + if err := f.hook(ctx, e.Name); err != nil { + return err + } + } + return f.MemFiler.UpdateEntry(ctx, dir, e, expected) +} + +// headNamesMissing reports a name some root in HEAD (current or snapshot) +// names that is absent from the pool: K6 broken. +func headNamesMissing(ctx context.Context, c *BCatalog, v VolumeRef) error { + s, r, err := c.open(v) + if err != nil { + return err + } + h, found, err := s.ReadHead(ctx) + if err != nil || !found { + return fmt.Errorf("HEAD: found %v, %v", found, err) + } + var missing error + for _, rn := range layout.HeadRoots(h) { + for shard := uint64(0); shard < 2; shard++ { + if err := r.EachRef(ctx, rn, shard, func(_ uint64, ref layout.Ref) bool { + if _, ok, err := s.Stat(ctx, ref.Chunk.Path()); err != nil || !ok { + missing = fmt.Errorf("root %v names %s, absent from the pool (%v)", rn, ref.Chunk, err) + return false + } + return true + }); err != nil { + return err + } + } + } + return missing +} + +// The operator deletes a snapshot while the holder's cleaning is open, after +// the cleaning took its HEAD view (OssSnap r4, osssnap4d witness +// WitDeleteDuringClean; Safe = K6). The delete is one HEAD update by nobody's +// lease and lands in the clean activity without ending it. The cleaning +// keeps every chunk its view named (the deleted snapshot's chunk survives +// this pass), never marks a chunk a root still names, and ends normally; +// the next cleaning removes the chunk only the deleted snapshot named. +// Must violate: a cleaning that counts only the current root (the model's +// LiveCurOnly) marks the snapshot's chunk while the snapshot still names it. +func TestBCatalog_OperatorSnapshotDeleteDuringACleaning(t *testing.T) { + ctx := context.Background() + f := &markHookFiler{MemFiler: NewMemFiler()} + c, err := NewBCatalog(f, newFakeBlobs(), "/blocks") + if err != nil { + t.Fatal(err) + } + v := newRef(t, "v1") + g := layout.Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4 * 4096} + if _, err := c.CreateVolume(ctx, v, g); err != nil { + t.Fatal(err) + } + s, err := c.Store(v) + if err != nil { + t.Fatal(err) + } + if _, err := layout.Start(ctx, s, okClaimLease{}, layout.HolderID{Epoch: 1, Holder: "s/r"}, layout.LocalRoot{Geometry: g, ClaimID: "k", Fresh: true, CanStartFrom: anyStart}); err != nil { + t.Fatal(err) + } + // s1 names X at index 1; the current root (and s2) moved on to Y. + x, y := bytes.Repeat([]byte{'X'}, 4096), bytes.Repeat([]byte{'Y'}, 4096) + cx, cy := layout.NameChunk(1, x), layout.NameChunk(1, y) + m1 := map[uint64]layout.Ref{1: {Owner: v.Name, OwnerID: v.ID, Chunk: cx}} + m2 := map[uint64]layout.Ref{1: {Owner: v.Name, OwnerID: v.ID, Chunk: cy}} + commitImage(t, s, v.Name, "w1", map[uint64]layout.Ref{}, m1, map[uint64][]byte{1: x}, 1, "s1") + commitImage(t, s, v.Name, "w2", m1, m2, map[uint64][]byte{1: y}, 2, "s2") + // Z at index 2: an orphan no root names, so the pass marks something. + z := bytes.Repeat([]byte{'Z'}, 4096) + cz := layout.NameChunk(2, z) + if err := layout.EnsureObject(ctx, s, cz.Path(), z, "dead-session"); err != nil { + t.Fatal(err) + } + if err := f.MemFiler.CreateEntry(ctx, path.Join(c.base, v.Dir(), layout.PoolDir), &filerpb.Entry{Name: "0", IsDirectory: true}, false); err != nil { + t.Fatal(err) + } + + // At the pass's first MARK (its HEAD view is taken): check K6 for the + // name being marked, then the operator deletes s1. + deleted := false + var hookErr error + f.hook = func(ctx context.Context, name string) error { + h, _, err := c.ReadHead(ctx, v) + if err != nil { + hookErr = err + return err + } + for _, rn := range layout.HeadRoots(h) { + _, r, _ := c.open(v) + _ = r.EachRef(ctx, rn, 0, func(_ uint64, ref layout.Ref) bool { + if ref.Chunk.Path() != "" && path.Base(ref.Chunk.Path()) == name && hookErr == nil { + hookErr = fmt.Errorf("the cleaning marks %s while root %v still names it", name, rn) + } + return true + }) + } + if deleted { + return nil + } + deleted = true + session := h.Activity.Session + if h.Activity.Kind != layout.ActClean { + hookErr = fmt.Errorf("HEAD at the first mark: %+v; want the cleaning open", h.Activity) + return nil + } + after, err := c.DeleteSnapshot(ctx, v, "s1") + if err != nil { + hookErr = fmt.Errorf("the operator's delete during a cleaning: %w", err) + return nil + } + if after.Activity != (layout.Activity{Kind: layout.ActClean, Session: session}) { + hookErr = fmt.Errorf("HEAD after the operator's delete: %+v; want the cleaning still open", after.Activity) + } + return nil + } + res, _, err := cleanVia(ctx, c, v, cleanHolder) + if hookErr != nil { + t.Fatal(hookErr) + } + if err != nil || !deleted { + t.Fatalf("the pass with the delete in it: %+v %v (delete ran: %v)", res, err, deleted) + } + if !present(t, s, cx) || !present(t, s, cy) || present(t, s, cz) { + t.Fatalf("after the pass: X %v, Y %v, Z %v; want X kept (its view named it), Y kept, Z removed", + present(t, s, cx), present(t, s, cy), present(t, s, cz)) + } + h, _, err := c.ReadHead(ctx, v) + if _, s1 := h.Snapshots["s1"]; err != nil || h.Activity.Kind != layout.ActIdle || s1 { + t.Fatalf("HEAD after the pass: %+v %v; want idle and s1 gone", h.Activity, err) + } + if err := headNamesMissing(ctx, c, v); err != nil { + t.Fatal(err) + } + // Convergence: the next cleaning removes the chunk only s1 named. + f.hook = nil + res, _, err = cleanVia(ctx, c, v, cleanHolder) + if err != nil || res.Removed != 1 || present(t, s, cx) || !present(t, s, cy) { + t.Fatalf("the next pass: %+v %v, X %v, Y %v; want X removed, Y kept", res, err, present(t, s, cx), present(t, s, cy)) + } + if err := headNamesMissing(ctx, c, v); err != nil { + t.Fatal(err) + } +} From a49d00b3a3f5527e644eff412d7907a22b10e52d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 13:37:15 -0800 Subject: [PATCH 2/6] chunkstore: a stock filer refuses HEAD's wrong-condition writes The store adapter needs no model only if the filer's conditional write holds. On a real weed filer: a second exclusive create, a stale and a future generation, and the right generation under another volume's identity are each refused by the filer and leave HEAD's generation and bytes unchanged; the same write with the true condition lands. Co-Authored-By: Claude Opus 5.5 --- .../layout_head_cas_integration_test.go | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 seaweed-block/core/frontend/chunkstore/layout_head_cas_integration_test.go diff --git a/seaweed-block/core/frontend/chunkstore/layout_head_cas_integration_test.go b/seaweed-block/core/frontend/chunkstore/layout_head_cas_integration_test.go new file mode 100644 index 0000000000..942eb26499 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/layout_head_cas_integration_test.go @@ -0,0 +1,97 @@ +//go:build chunkstore_integration + +package chunkstore + +import ( + "bytes" + "context" + "errors" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +// The store adapter's premise on a real filer (stock weed): HEAD is written +// only by a conditional write the filer itself refuses when the condition +// is false, and a refused write changes nothing. Every case sends a wrong +// condition to the filer (not refused locally) and then reads HEAD back: +// a second exclusive create, a stale generation, a future generation, and +// the right generation under another volume's identity. +func TestIntegration_HeadConditionalWritesRefusedByAStockFiler(t *testing.T) { + c := startWeed(t) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + id, err := layout.NewVolumeID() + if err != nil { + t.Fatal(err) + } + other, err := layout.NewVolumeID() + if err != nil { + t.Fatal(err) + } + root := "/swblock/heads/" + layout.VolumeDir("v1", id) + cl := c.client(t, root+"/") + s, err := NewLayoutStore(cl, cl, root, id) + if err != nil { + t.Fatal(err) + } + rn := layout.RootName{Hash: layout.Sum([]byte("root"))} + at := func(vol layout.VolumeID, pos uint64) layout.Head { + return layout.Head{VolumeID: vol, Epoch: 3, Holder: "node/r", ClaimID: "claim", Activity: layout.Activity{Kind: layout.ActIdle}, Current: &rn, Position: pos, State: layout.StateLive} + } + // want reads HEAD back and requires generation gen and exactly h's bytes. + want := func(step string, gen uint64, h layout.Head) { + t.Helper() + got, found, err := s.ReadHead(ctx) + if err != nil || !found { + t.Fatalf("%s: HEAD found %v, %v", step, found, err) + } + a, _ := got.Encode() + b, _ := h.Encode() + if got.Gen != gen || !bytes.Equal(a, b) { + t.Fatalf("%s: HEAD at gen %d position %d; want gen %d position %d, unchanged bytes", step, got.Gen, got.Position, gen, h.Position) + } + } + refused := func(step string, err error) { + t.Helper() + if !errors.Is(err, layout.ErrPrecondition) { + t.Fatalf("%s: %v; want refused by the filer (precondition)", step, err) + } + } + + h1 := layout.Unclaimed(id, nil) + if err := s.CreateHead(ctx, h1); err != nil { + t.Fatal(err) + } + want("create", 1, h1) + refused("a second exclusive create", s.UpdateHead(ctx, 0, at(id, 9))) + want("after the refused create", 1, h1) + + h2 := at(id, 42) + if err := s.UpdateHead(ctx, 1, h2); err != nil { + t.Fatalf("update at the current generation: %v", err) + } + want("update", 2, h2) + refused("a stale generation", s.UpdateHead(ctx, 1, at(id, 43))) + want("after the stale update", 2, h2) + refused("a future generation", s.UpdateHead(ctx, 5, at(id, 44))) + want("after the future update", 2, h2) + + // The right generation, but the condition names another volume: the + // write leaves the adapter (its own identity check passes) and the filer + // refuses it on the volume attribute. + foreign, err := NewLayoutStore(cl, cl, root, other) + if err != nil { + t.Fatal(err) + } + refused("another volume's identity", foreign.UpdateHead(ctx, 2, at(other, 45))) + want("after the foreign update", 2, h2) + + // Control: the same write with the true condition lands. + h3 := at(id, 46) + if err := s.UpdateHead(ctx, 2, h3); err != nil { + t.Fatalf("control update: %v", err) + } + want("control", 3, h3) +} From aecce190ac8eb58585f501f0e1f45f0e2f67c3c0 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 14:45:19 -0800 Subject: [PATCH 3/6] chunkstore: concurrent conditional writes on a stock filer have one winner The cutover removed the store's concurrent CAS test with the legacy store. This one runs on the layout store against a real weed: 16 writers, each on its own connection, are held at the filer write until all have arrived (after every client-side pre-read) and released together, 4 rounds each, for HEAD updates at one generation, exclusive HEAD creates, MARKs of one object entry, and conditional deletes of it. Exactly one writer succeeds at the filer, the others are refused, and the entry holds the winner's bytes; a delete with a mark the entry never carried never succeeds. Co-Authored-By: Claude Opus 5.5 --- .../layout_concurrent_cas_integration_test.go | 316 ++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go diff --git a/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go b/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go new file mode 100644 index 0000000000..5698515466 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go @@ -0,0 +1,316 @@ +//go:build chunkstore_integration + +package chunkstore + +import ( + "bytes" + "context" + "crypto/sha256" + "errors" + "fmt" + "io" + "os" + "sync" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" + "google.golang.org/grpc" + "google.golang.org/grpc/status" +) + +// writeGate does not implement any condition: every write is the real filer +// RPC. It holds each write until every writer of the round has reached it +// (after all client-side pre-reads), releases them together, and records +// the real outcome, so a client-side refusal cannot stand in for the +// filer's conditional write. +type writeGate struct { + filerpb.SeaweedFilerClient + index int + arrived chan<- int + release <-chan struct{} + outcomes chan<- gateOutcome +} + +type gateOutcome struct { + index int + ok bool + what string +} + +func (g *writeGate) hold(ctx context.Context) error { + select { + case g.arrived <- g.index: + case <-ctx.Done(): + return ctx.Err() + } + select { + case <-g.release: + return nil + case <-ctx.Done(): + return ctx.Err() + } +} + +func (g *writeGate) CreateEntry(ctx context.Context, in *filerpb.CreateEntryRequest, opts ...grpc.CallOption) (*filerpb.CreateEntryResponse, error) { + if err := g.hold(ctx); err != nil { + return nil, err + } + resp, err := g.SeaweedFilerClient.CreateEntry(ctx, in, opts...) + ok := err == nil && resp.GetErrorCode() == filerpb.FilerError_OK && resp.GetError() == "" + g.outcomes <- gateOutcome{g.index, ok, fmt.Sprintf("grpc=%s code=%s", status.Code(err), resp.GetErrorCode())} + return resp, err +} + +func (g *writeGate) UpdateEntry(ctx context.Context, in *filerpb.UpdateEntryRequest, opts ...grpc.CallOption) (*filerpb.UpdateEntryResponse, error) { + if err := g.hold(ctx); err != nil { + return nil, err + } + resp, err := g.SeaweedFilerClient.UpdateEntry(ctx, in, opts...) + g.outcomes <- gateOutcome{g.index, err == nil, fmt.Sprintf("grpc=%s", status.Code(err))} + return resp, err +} + +func (g *writeGate) DeleteEntry(ctx context.Context, in *filerpb.DeleteEntryRequest, opts ...grpc.CallOption) (*filerpb.DeleteEntryResponse, error) { + if err := g.hold(ctx); err != nil { + return nil, err + } + resp, err := g.SeaweedFilerClient.DeleteEntry(ctx, in, opts...) + g.outcomes <- gateOutcome{g.index, err == nil && resp.GetError() == "", fmt.Sprintf("grpc=%s", status.Code(err))} + return resp, err +} + +const ( + casWriters = 16 // writers per round, as the store's earlier concurrent test + casRounds = 4 +) + +// raceRound gives each of n writers its own real filer connection behind a +// gate, runs op on all of them at once, and returns each writer's result and +// the filer's real outcome per writer. +func raceRound(t *testing.T, c *weedCluster, root string, id layout.VolumeID, op func(ctx context.Context, i int, s *LayoutStore) error) (errs []error, filer []gateOutcome) { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + defer cancel() + arrived := make(chan int, casWriters) + release := make(chan struct{}) + outcomes := make(chan gateOutcome, casWriters) + stores := make([]*LayoutStore, casWriters) + for i := range stores { + cl := c.client(t, root+"/") + cl.fc = &writeGate{SeaweedFilerClient: cl.fc, index: i, arrived: arrived, release: release, outcomes: outcomes} + s, err := NewLayoutStore(cl, cl, root, id) + if err != nil { + t.Fatal(err) + } + stores[i] = s + } + errs = make([]error, casWriters) + var wg sync.WaitGroup + for i := range stores { + wg.Add(1) + go func(i int) { + defer wg.Done() + errs[i] = op(ctx, i, stores[i]) + }(i) + } + var once sync.Once + defer once.Do(func() { close(release) }) + seen := map[int]bool{} + for len(seen) < casWriters { + select { + case i := <-arrived: + if seen[i] { + t.Fatalf("writer %d reached the filer twice", i) + } + seen[i] = true + case <-ctx.Done(): + t.Fatalf("only %d/%d writers reached the filer write: %v", len(seen), casWriters, ctx.Err()) + } + } + once.Do(func() { close(release) }) + wg.Wait() + close(outcomes) + for o := range outcomes { + filer = append(filer, o) + } + if len(filer) != casWriters { + t.Fatalf("%d filer outcomes recorded; want %d", len(filer), casWriters) + } + return errs, filer +} + +// oneWinner requires exactly one writer to succeed at the filer and in its +// caller, every other caller refused with a precondition, and returns the +// winner. +func oneWinner(t *testing.T, step string, errs []error, filer []gateOutcome) int { + t.Helper() + won := -1 + for _, o := range filer { + if o.ok { + if won >= 0 { + t.Fatalf("%s: writers %d and %d both succeeded at the filer", step, won, o.index) + } + won = o.index + } + } + if won < 0 { + t.Fatalf("%s: no writer succeeded at the filer: %+v", step, filer) + } + for i, err := range errs { + switch { + case i == won && err != nil: + t.Fatalf("%s: the filer's winner %d reported %v", step, i, err) + case i != won && !errors.Is(err, layout.ErrPrecondition): + t.Fatalf("%s: writer %d lost at the filer but reported %v; want a precondition refusal", step, i, err) + } + } + return won +} + +func logWeedBinary(t *testing.T) { + t.Helper() + f, err := os.Open(os.Getenv("CHUNKSTORE_WEED")) + if err != nil { + return + } + defer f.Close() + h := sha256.New() + if _, err := io.Copy(h, f); err == nil { + t.Logf("real filer binary SHA256=%x", h.Sum(nil)) + } +} + +// Concurrent conditional writes on a real filer (stock weed): of 16 writers +// released together with the same condition, the filer lets exactly one +// through and refuses the rest, and the entry holds the winner's bytes. For +// HEAD updates at one generation, for exclusive HEAD creates, for MARKs on +// one object entry, and for conditional deletes of it. +func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { + c := startWeed(t) + logWeedBinary(t) + rn := layout.RootName{Hash: layout.Sum([]byte("root"))} + at := func(vol layout.VolumeID, pos uint64) layout.Head { + return layout.Head{VolumeID: vol, Epoch: 3, Holder: "node/r", ClaimID: "claim", Activity: layout.Activity{Kind: layout.ActIdle}, Current: &rn, Position: pos, State: layout.StateLive} + } + newVolume := func(t *testing.T, kind string) (string, layout.VolumeID, *LayoutStore) { + t.Helper() + id, err := layout.NewVolumeID() + if err != nil { + t.Fatal(err) + } + root := "/swblock/cas-" + kind + "/" + layout.VolumeDir("v1", id) + cl := c.client(t, root+"/") + s, err := NewLayoutStore(cl, cl, root, id) + if err != nil { + t.Fatal(err) + } + return root, id, s + } + headIs := func(t *testing.T, s *LayoutStore, gen uint64, want layout.Head) { + t.Helper() + got, found, err := s.ReadHead(context.Background()) + if err != nil || !found { + t.Fatalf("HEAD: found %v, %v", found, err) + } + a, _ := got.Encode() + b, _ := want.Encode() + if got.Gen != gen || !bytes.Equal(a, b) { + t.Fatalf("HEAD at gen %d position %d; want the winner's bytes at gen %d (position %d)", got.Gen, got.Position, gen, want.Position) + } + } + + t.Run("HEAD update at one generation", func(t *testing.T) { + root, id, s := newVolume(t, "update") + if err := s.CreateHead(context.Background(), layout.Unclaimed(id, nil)); err != nil { + t.Fatal(err) + } + for round := 0; round < casRounds; round++ { + gen := uint64(round + 1) + proposal := func(i int) layout.Head { return at(id, uint64(1000*round+i+1)) } + errs, filer := raceRound(t, c, root, id, func(ctx context.Context, i int, s *LayoutStore) error { + return s.UpdateHead(ctx, gen, proposal(i)) + }) + won := oneWinner(t, fmt.Sprintf("round %d", round), errs, filer) + headIs(t, s, gen+1, proposal(won)) + } + }) + + t.Run("exclusive HEAD create", func(t *testing.T) { + for round := 0; round < casRounds; round++ { + root, id, s := newVolume(t, "create") + proposal := func(i int) layout.Head { return at(id, uint64(i+1)) } + errs, filer := raceRound(t, c, root, id, func(ctx context.Context, i int, s *LayoutStore) error { + return s.UpdateHead(ctx, 0, proposal(i)) + }) + won := oneWinner(t, fmt.Sprintf("round %d", round), errs, filer) + headIs(t, s, 1, proposal(won)) + } + }) + + t.Run("MARK of one object entry", func(t *testing.T) { + root, id, s := newVolume(t, "mark") + for round := 0; round < casRounds; round++ { + data := []byte(fmt.Sprintf("orphan-%d", round)) + rel := layout.NameChunk(uint64(round+1), data).Path() + if err := layout.EnsureObject(context.Background(), s, rel, data, "s0"); err != nil { + t.Fatal(err) + } + plan, found, err := s.Stat(context.Background(), rel) + if err != nil || !found { + t.Fatalf("object: found %v, %v", found, err) + } + mark := func(i int) string { return fmt.Sprintf("c%d-%d", round, i) } + errs, filer := raceRound(t, c, root, id, func(ctx context.Context, i int, s *LayoutStore) error { + return s.Mark(ctx, rel, plan, mark(i)) + }) + won := oneWinner(t, fmt.Sprintf("round %d", round), errs, filer) + if m, _, _ := s.Stat(context.Background(), rel); m.Mark != mark(won) { + t.Fatalf("round %d: entry carries mark %q; want the winner's %q", round, m.Mark, mark(won)) + } + } + }) + + t.Run("conditional delete of one object entry", func(t *testing.T) { + root, id, s := newVolume(t, "delete") + for round := 0; round < casRounds; round++ { + data := []byte(fmt.Sprintf("marked-%d", round)) + rel := layout.NameChunk(uint64(round+1), data).Path() + if err := layout.EnsureObject(context.Background(), s, rel, data, "s0"); err != nil { + t.Fatal(err) + } + plan, _, _ := s.Stat(context.Background(), rel) + const own = "c-own" + if err := s.Mark(context.Background(), rel, plan, own); err != nil { + t.Fatal(err) + } + // Writer 0 holds the entry's mark; the 15 others name marks the + // entry never carried. Only writer 0 may delete it; a refused + // delete of an entry already gone is no error to its caller, so + // the filer's own outcomes decide. + errs, filer := raceRound(t, c, root, id, func(ctx context.Context, i int, s *LayoutStore) error { + if i == 0 { + return s.DeleteMarked(ctx, rel, own) + } + return s.DeleteMarked(ctx, rel, fmt.Sprintf("c-other-%d", i)) + }) + for _, o := range filer { + if o.ok && o.index != 0 { + t.Fatalf("round %d: writer %d deleted the entry with a mark it never carried (%s)", round, o.index, o.what) + } + if !o.ok && o.index == 0 { + t.Fatalf("round %d: the delete with the entry's own mark was refused (%s)", round, o.what) + } + } + for i, err := range errs { + if err != nil && !errors.Is(err, layout.ErrPrecondition) { + t.Fatalf("round %d: writer %d: %v", round, i, err) + } + } + if _, found, _ := s.Stat(context.Background(), rel); found { + t.Fatalf("round %d: the entry survived its own conditional delete", round) + } + } + }) +} From f66d796baab882e6ba3709407a00b4f1a1b78d05 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 15:52:18 -0800 Subject: [PATCH 4/6] chunkstore: a stock filer lets either the delete or one reuse of a marked entry through Cleaning is on by default, so the remover's DELETE and a successor's REUSE of the same marked entry race in production. On a real weed, 16 writers per round (half DELETE with the entry's mark, half REUSE on the metadata they read) are released together: exactly one succeeds at the filer. A delete leaves no entry and every reuse refused; a reuse leaves the entry unmarked under its session and every delete and other reuse refused. Never both. The fixture's readbacks fail the test on a read error (an unreadable entry is never taken as absent), and each subtest bounds its setup and readbacks with its own deadline. Co-Authored-By: Claude Opus 5.5 --- .../layout_concurrent_cas_integration_test.go | 148 ++++++++++++++++-- 1 file changed, 133 insertions(+), 15 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go b/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go index 5698515466..35dda84470 100644 --- a/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go @@ -31,6 +31,7 @@ type writeGate struct { arrived chan<- int release <-chan struct{} outcomes chan<- gateOutcome + lag time.Duration // after the common release } type gateOutcome struct { @@ -47,10 +48,13 @@ func (g *writeGate) hold(ctx context.Context) error { } select { case <-g.release: - return nil case <-ctx.Done(): return ctx.Err() } + if g.lag > 0 { + time.Sleep(g.lag) + } + return nil } func (g *writeGate) CreateEntry(ctx context.Context, in *filerpb.CreateEntryRequest, opts ...grpc.CallOption) (*filerpb.CreateEntryResponse, error) { @@ -90,6 +94,12 @@ const ( // gate, runs op on all of them at once, and returns each writer's result and // the filer's real outcome per writer. func raceRound(t *testing.T, c *weedCluster, root string, id layout.VolumeID, op func(ctx context.Context, i int, s *LayoutStore) error) (errs []error, filer []gateOutcome) { + return raceRoundLag(t, c, root, id, nil, op) +} + +// raceRoundLag is raceRound with lag(i) added to writer i after the common +// release (nil: none), to bias which kind of writer reaches the filer first. +func raceRoundLag(t *testing.T, c *weedCluster, root string, id layout.VolumeID, lag func(i int) time.Duration, op func(ctx context.Context, i int, s *LayoutStore) error) (errs []error, filer []gateOutcome) { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() @@ -99,7 +109,11 @@ func raceRound(t *testing.T, c *weedCluster, root string, id layout.VolumeID, op stores := make([]*LayoutStore, casWriters) for i := range stores { cl := c.client(t, root+"/") - cl.fc = &writeGate{SeaweedFilerClient: cl.fc, index: i, arrived: arrived, release: release, outcomes: outcomes} + g := &writeGate{SeaweedFilerClient: cl.fc, index: i, arrived: arrived, release: release, outcomes: outcomes} + if lag != nil { + g.lag = lag(i) + } + cl.fc = g s, err := NewLayoutStore(cl, cl, root, id) if err != nil { t.Fatal(err) @@ -186,7 +200,8 @@ func logWeedBinary(t *testing.T) { // released together with the same condition, the filer lets exactly one // through and refuses the rest, and the entry holds the winner's bytes. For // HEAD updates at one generation, for exclusive HEAD creates, for MARKs on -// one object entry, and for conditional deletes of it. +// one object entry, for conditional deletes of it, and for a delete raced +// by reuses of the same marked entry. func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { c := startWeed(t) logWeedBinary(t) @@ -208,9 +223,19 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { } return root, id, s } - headIs := func(t *testing.T, s *LayoutStore, gen uint64, want layout.Head) { + // statOf reads an object's metadata back; a failed read fails the test + // (it is never taken as an absent entry). + statOf := func(ctx context.Context, t *testing.T, s *LayoutStore, rel string) (layout.ObjectMeta, bool) { t.Helper() - got, found, err := s.ReadHead(context.Background()) + m, found, err := s.Stat(ctx, rel) + if err != nil { + t.Fatalf("read back %s: %v", rel, err) + } + return m, found + } + headIs := func(ctx context.Context, t *testing.T, s *LayoutStore, gen uint64, want layout.Head) { + t.Helper() + got, found, err := s.ReadHead(ctx) if err != nil || !found { t.Fatalf("HEAD: found %v, %v", found, err) } @@ -222,8 +247,10 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { } t.Run("HEAD update at one generation", func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + defer cancel() root, id, s := newVolume(t, "update") - if err := s.CreateHead(context.Background(), layout.Unclaimed(id, nil)); err != nil { + if err := s.CreateHead(ctx, layout.Unclaimed(id, nil)); err != nil { t.Fatal(err) } for round := 0; round < casRounds; round++ { @@ -233,11 +260,13 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { return s.UpdateHead(ctx, gen, proposal(i)) }) won := oneWinner(t, fmt.Sprintf("round %d", round), errs, filer) - headIs(t, s, gen+1, proposal(won)) + headIs(ctx, t, s, gen+1, proposal(won)) } }) t.Run("exclusive HEAD create", func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + defer cancel() for round := 0; round < casRounds; round++ { root, id, s := newVolume(t, "create") proposal := func(i int) layout.Head { return at(id, uint64(i+1)) } @@ -245,19 +274,21 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { return s.UpdateHead(ctx, 0, proposal(i)) }) won := oneWinner(t, fmt.Sprintf("round %d", round), errs, filer) - headIs(t, s, 1, proposal(won)) + headIs(ctx, t, s, 1, proposal(won)) } }) t.Run("MARK of one object entry", func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + defer cancel() root, id, s := newVolume(t, "mark") for round := 0; round < casRounds; round++ { data := []byte(fmt.Sprintf("orphan-%d", round)) rel := layout.NameChunk(uint64(round+1), data).Path() - if err := layout.EnsureObject(context.Background(), s, rel, data, "s0"); err != nil { + if err := layout.EnsureObject(ctx, s, rel, data, "s0"); err != nil { t.Fatal(err) } - plan, found, err := s.Stat(context.Background(), rel) + plan, found, err := s.Stat(ctx, rel) if err != nil || !found { t.Fatalf("object: found %v, %v", found, err) } @@ -266,23 +297,28 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { return s.Mark(ctx, rel, plan, mark(i)) }) won := oneWinner(t, fmt.Sprintf("round %d", round), errs, filer) - if m, _, _ := s.Stat(context.Background(), rel); m.Mark != mark(won) { + if m, _ := statOf(ctx, t, s, rel); m.Mark != mark(won) { t.Fatalf("round %d: entry carries mark %q; want the winner's %q", round, m.Mark, mark(won)) } } }) t.Run("conditional delete of one object entry", func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + defer cancel() root, id, s := newVolume(t, "delete") for round := 0; round < casRounds; round++ { data := []byte(fmt.Sprintf("marked-%d", round)) rel := layout.NameChunk(uint64(round+1), data).Path() - if err := layout.EnsureObject(context.Background(), s, rel, data, "s0"); err != nil { + if err := layout.EnsureObject(ctx, s, rel, data, "s0"); err != nil { t.Fatal(err) } - plan, _, _ := s.Stat(context.Background(), rel) + plan, found := statOf(ctx, t, s, rel) + if !found { + t.Fatalf("round %d: object %s missing after create", round, rel) + } const own = "c-own" - if err := s.Mark(context.Background(), rel, plan, own); err != nil { + if err := s.Mark(ctx, rel, plan, own); err != nil { t.Fatal(err) } // Writer 0 holds the entry's mark; the 15 others name marks the @@ -308,9 +344,91 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { t.Fatalf("round %d: writer %d: %v", round, i, err) } } - if _, found, _ := s.Stat(context.Background(), rel); found { + if _, found := statOf(ctx, t, s, rel); found { t.Fatalf("round %d: the entry survived its own conditional delete", round) } } }) + + // A marked entry raced by its remover's DELETE and a successor's REUSE: + // half the writers delete with the entry's mark, half reuse it on the + // metadata they read (that mark). The filer lets exactly one through: + // either a delete, and every reuse is refused (the entry is gone), or + // one reuse, and every delete and every other reuse is refused (the + // entry stays, unmarked, under the reuser's session). Never both. + t.Run("DELETE against REUSE of one marked entry", func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + defer cancel() + root, id, s := newVolume(t, "delreuse") + deletes, reuses := 0, 0 + for round := 0; round < 2*casRounds; round++ { + data := []byte(fmt.Sprintf("raced-%d", round)) + rel := layout.NameChunk(uint64(round+1), data).Path() + if err := layout.EnsureObject(ctx, s, rel, data, "s0"); err != nil { + t.Fatal(err) + } + plan, found := statOf(ctx, t, s, rel) + if !found { + t.Fatalf("round %d: object %s missing after create", round, rel) + } + const m = "c-mark" + if err := s.Mark(ctx, rel, plan, m); err != nil { + t.Fatal(err) + } + marked := layout.ObjectMeta{Session: "s0", Mark: m, Volume: id} + reuser := func(i int) string { return fmt.Sprintf("r%d-%d", round, i) } + // Alternate rounds hold back the reuses or the deletes by a few + // milliseconds, so both outcomes occur; the filer still decides. + lag := func(i int) time.Duration { + if (i%2 == 0) == (round%2 == 1) { + return 5 * time.Millisecond + } + return 0 + } + errs, filer := raceRoundLag(t, c, root, id, lag, func(ctx context.Context, i int, s *LayoutStore) error { + if i%2 == 0 { + return s.DeleteMarked(ctx, rel, m) + } + return s.Reuse(ctx, rel, marked, reuser(i)) + }) + won := -1 + for _, o := range filer { + if o.ok { + if won >= 0 { + t.Fatalf("round %d: writers %d and %d both succeeded at the filer (%s)", round, won, o.index, o.what) + } + won = o.index + } + } + if won < 0 { + t.Fatalf("round %d: neither a delete nor a reuse succeeded: %+v", round, filer) + } + meta, found := statOf(ctx, t, s, rel) + if won%2 == 0 { + deletes++ + if found { + t.Fatalf("round %d: delete %d won but the entry remains: %+v", round, won, meta) + } + for i := 1; i < casWriters; i += 2 { + if !errors.Is(errs[i], layout.ErrPrecondition) { + t.Fatalf("round %d: reuse %d after the delete: %v; want refused", round, i, errs[i]) + } + } + continue + } + reuses++ + if !found || meta != (layout.ObjectMeta{Session: reuser(won), Volume: id}) { + t.Fatalf("round %d: reuse %d won; entry %+v (found %v); want its session, unmarked", round, won, meta, found) + } + for i, err := range errs { + if i != won && !errors.Is(err, layout.ErrPrecondition) { + t.Fatalf("round %d: writer %d after reuse %d won: %v; want refused", round, i, won, err) + } + } + } + t.Logf("%d rounds: a delete won %d, a reuse won %d", 2*casRounds, deletes, reuses) + if deletes == 0 || reuses == 0 { + t.Fatalf("only one outcome occurred (deletes %d, reuses %d): the other branch was never checked", deletes, reuses) + } + }) } From d018a9d396516616139ae7fc5c168f995485b6c3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 16:03:49 -0800 Subject: [PATCH 5/6] chunkstore: race DELETE against REUSE with both released at the same instant The lagged rounds only showed one write after the other (a 5 ms lag against a ~1 ms conditional write), never a delete whose check and removal overlap a reuse in flight. 128 rounds now release both kinds at the same instant, with the same assertions whichever wins; the 8 lagged rounds stay, for outcome coverage. The writers' 16 connections are kept across rounds. Co-Authored-By: Claude Opus 5.5 --- .../layout_concurrent_cas_integration_test.go | 117 +++++++++++++----- 1 file changed, 85 insertions(+), 32 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go b/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go index 35dda84470..7e14cd70e3 100644 --- a/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout_concurrent_cas_integration_test.go @@ -101,32 +101,55 @@ func raceRound(t *testing.T, c *weedCluster, root string, id layout.VolumeID, op // release (nil: none), to bias which kind of writer reaches the filer first. func raceRoundLag(t *testing.T, c *weedCluster, root string, id layout.VolumeID, lag func(i int) time.Duration, op func(ctx context.Context, i int, s *LayoutStore) error) (errs []error, filer []gateOutcome) { t.Helper() - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) - defer cancel() - arrived := make(chan int, casWriters) - release := make(chan struct{}) - outcomes := make(chan gateOutcome, casWriters) - stores := make([]*LayoutStore, casWriters) - for i := range stores { + return newRacers(t, c, root, id).round(t, lag, op) +} + +// racers are casWriters gated writers, each on its own real filer +// connection, kept across rounds (many rounds would otherwise open a +// connection per writer per round). +type racers struct { + gates []*writeGate + stores []*LayoutStore +} + +func newRacers(t *testing.T, c *weedCluster, root string, id layout.VolumeID) *racers { + t.Helper() + r := &racers{} + for i := 0; i < casWriters; i++ { cl := c.client(t, root+"/") - g := &writeGate{SeaweedFilerClient: cl.fc, index: i, arrived: arrived, release: release, outcomes: outcomes} - if lag != nil { - g.lag = lag(i) - } + g := &writeGate{SeaweedFilerClient: cl.fc, index: i} cl.fc = g s, err := NewLayoutStore(cl, cl, root, id) if err != nil { t.Fatal(err) } - stores[i] = s + r.gates, r.stores = append(r.gates, g), append(r.stores, s) + } + return r +} + +// round runs op on every writer at once: each is held at its filer write +// until all have arrived, then all are released together (plus lag(i)). +func (r *racers) round(t *testing.T, lag func(i int) time.Duration, op func(ctx context.Context, i int, s *LayoutStore) error) (errs []error, filer []gateOutcome) { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + defer cancel() + arrived := make(chan int, casWriters) + release := make(chan struct{}) + outcomes := make(chan gateOutcome, casWriters) + for i, g := range r.gates { + g.arrived, g.release, g.outcomes, g.lag = arrived, release, outcomes, 0 + if lag != nil { + g.lag = lag(i) + } } errs = make([]error, casWriters) var wg sync.WaitGroup - for i := range stores { + for i := range r.stores { wg.Add(1) go func(i int) { defer wg.Done() - errs[i] = op(ctx, i, stores[i]) + errs[i] = op(ctx, i, r.stores[i]) }(i) } var once sync.Once @@ -356,12 +379,18 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { // either a delete, and every reuse is refused (the entry is gone), or // one reuse, and every delete and every other reuse is refused (the // entry stays, unmarked, under the reuser's session). Never both. + // casSimultaneous rounds release both kinds at the same instant (the + // race itself, whichever wins); the lagged rounds then hold one kind + // back a few milliseconds so that each outcome is seen at least once. t.Run("DELETE against REUSE of one marked entry", func(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() root, id, s := newVolume(t, "delreuse") - deletes, reuses := 0, 0 - for round := 0; round < 2*casRounds; round++ { + r := newRacers(t, c, root, id) + const casSimultaneous = 128 + const m = "c-mark" + race := func(round int, lag func(i int) time.Duration) (deleteWon bool) { + t.Helper() data := []byte(fmt.Sprintf("raced-%d", round)) rel := layout.NameChunk(uint64(round+1), data).Path() if err := layout.EnsureObject(ctx, s, rel, data, "s0"); err != nil { @@ -371,21 +400,12 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { if !found { t.Fatalf("round %d: object %s missing after create", round, rel) } - const m = "c-mark" if err := s.Mark(ctx, rel, plan, m); err != nil { t.Fatal(err) } marked := layout.ObjectMeta{Session: "s0", Mark: m, Volume: id} reuser := func(i int) string { return fmt.Sprintf("r%d-%d", round, i) } - // Alternate rounds hold back the reuses or the deletes by a few - // milliseconds, so both outcomes occur; the filer still decides. - lag := func(i int) time.Duration { - if (i%2 == 0) == (round%2 == 1) { - return 5 * time.Millisecond - } - return 0 - } - errs, filer := raceRoundLag(t, c, root, id, lag, func(ctx context.Context, i int, s *LayoutStore) error { + errs, filer := r.round(t, lag, func(ctx context.Context, i int, s *LayoutStore) error { if i%2 == 0 { return s.DeleteMarked(ctx, rel, m) } @@ -403,9 +423,11 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { if won < 0 { t.Fatalf("round %d: neither a delete nor a reuse succeeded: %+v", round, filer) } + if errs[won] != nil { + t.Fatalf("round %d: the filer's winner %d reported %v", round, won, errs[won]) + } meta, found := statOf(ctx, t, s, rel) if won%2 == 0 { - deletes++ if found { t.Fatalf("round %d: delete %d won but the entry remains: %+v", round, won, meta) } @@ -414,9 +436,16 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { t.Fatalf("round %d: reuse %d after the delete: %v; want refused", round, i, errs[i]) } } - continue + // The other deletes lost at the filer; a refused delete of an + // entry already gone is no error to its caller, and nothing else + // is allowed. + for i := 0; i < casWriters; i += 2 { + if i != won && errs[i] != nil && !errors.Is(errs[i], layout.ErrPrecondition) { + t.Fatalf("round %d: delete %d after delete %d won: %v", round, i, won, errs[i]) + } + } + return true } - reuses++ if !found || meta != (layout.ObjectMeta{Session: reuser(won), Volume: id}) { t.Fatalf("round %d: reuse %d won; entry %+v (found %v); want its session, unmarked", round, won, meta, found) } @@ -425,10 +454,34 @@ func TestIntegration_ConcurrentConditionalWritesOneWinner(t *testing.T) { t.Fatalf("round %d: writer %d after reuse %d won: %v; want refused", round, i, won, err) } } + return false } - t.Logf("%d rounds: a delete won %d, a reuse won %d", 2*casRounds, deletes, reuses) + simDeletes := 0 + for round := 0; round < casSimultaneous; round++ { + if race(round, nil) { + simDeletes++ + } + } + t.Logf("%d simultaneous rounds: a delete won %d, a reuse won %d, never both", casSimultaneous, simDeletes, casSimultaneous-simDeletes) + deletes, reuses := 0, 0 + for k := 0; k < 2*casRounds; k++ { + round := casSimultaneous + k + // Alternate rounds hold back the reuses or the deletes. + lag := func(i int) time.Duration { + if (i%2 == 0) == (k%2 == 1) { + return 5 * time.Millisecond + } + return 0 + } + if race(round, lag) { + deletes++ + } else { + reuses++ + } + } + t.Logf("%d lagged rounds: a delete won %d, a reuse won %d", 2*casRounds, deletes, reuses) if deletes == 0 || reuses == 0 { - t.Fatalf("only one outcome occurred (deletes %d, reuses %d): the other branch was never checked", deletes, reuses) + t.Fatalf("only one outcome occurred in the lagged rounds (deletes %d, reuses %d): the other branch was never checked", deletes, reuses) } }) } From 63bff3a5c03bfb67513d44bb9fe0a113088170f8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 16:55:42 -0800 Subject: [PATCH 6/6] chunkstore: the cleaning test's comments use the public model name Co-Authored-By: Claude Opus 5.5 --- .../frontend/chunkstore/clean_opdelete_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go b/seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go index 9cf1334770..9bfa5a7991 100644 --- a/seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go +++ b/seaweed-block/core/frontend/chunkstore/clean_opdelete_test.go @@ -28,7 +28,7 @@ func (f *markHookFiler) UpdateEntry(ctx context.Context, dir string, e *filerpb. } // headNamesMissing reports a name some root in HEAD (current or snapshot) -// names that is absent from the pool: K6 broken. +// names that is absent from the pool: a root names a removed chunk. func headNamesMissing(ctx context.Context, c *BCatalog, v VolumeRef) error { s, r, err := c.open(v) if err != nil { @@ -56,14 +56,16 @@ func headNamesMissing(ctx context.Context, c *BCatalog, v VolumeRef) error { } // The operator deletes a snapshot while the holder's cleaning is open, after -// the cleaning took its HEAD view (OssSnap r4, osssnap4d witness -// WitDeleteDuringClean; Safe = K6). The delete is one HEAD update by nobody's -// lease and lands in the clean activity without ending it. The cleaning +// the cleaning took its HEAD view (model SnapshotRemoval.DeleteSnap during a +// cleaning; its safety property: every chunk a root names exists). The +// delete is one HEAD update by nobody's lease and lands in the clean +// activity without ending it. The cleaning // keeps every chunk its view named (the deleted snapshot's chunk survives // this pass), never marks a chunk a root still names, and ends normally; // the next cleaning removes the chunk only the deleted snapshot named. // Must violate: a cleaning that counts only the current root (the model's -// LiveCurOnly) marks the snapshot's chunk while the snapshot still names it. +// must-violate variant) marks the snapshot's chunk while the snapshot still +// names it. func TestBCatalog_OperatorSnapshotDeleteDuringACleaning(t *testing.T) { ctx := context.Background() f := &markHookFiler{MemFiler: NewMemFiler()} @@ -100,8 +102,8 @@ func TestBCatalog_OperatorSnapshotDeleteDuringACleaning(t *testing.T) { t.Fatal(err) } - // At the pass's first MARK (its HEAD view is taken): check K6 for the - // name being marked, then the operator deletes s1. + // At the pass's first MARK (its HEAD view is taken): check that no root + // names the name being marked, then the operator deletes s1. deleted := false var hookErr error f.hook = func(ctx context.Context, name string) error {