Merge pull request #709 from seaweedfs/fix/verify-production-layout

Fix verification of production volume directories
This commit is contained in:
Ping Qiu authored and GitHub committed 2026-11-29 00:45:41 -08:00
commit 0950e8f493
14 files changed
+336 -96

No files matched your search

+21 -8
View File
@@ -15,7 +15,7 @@ import (
"github.com/seaweedfs/seaweed-block/core/ops"
)
// chunkVerify: sw-block ops chunk verify --volume v --chunk-filer host:port
// chunkVerify: sw-block ops chunk verify --master master:9180 --volume v --chunk-filer host:port
// checks the volume's store read-only: VOLUME, HEAD, every root HEAD names
// (the current image and every snapshot), their segments and chunks
// (chunkstore.VerifyLayout). --orphans also reports the volume's own names
@@ -25,13 +25,14 @@ import (
func chunkVerify(args []string, stdout, stderr io.Writer) int {
fs := chunkFlagSet("verify", stderr)
var (
volumeID, filer, base, snapshot, depth string
allSnapshots, orphans bool
concurrency int
bytesPerSec int64
timeout time.Duration
volumeID, master, filer, base, snapshot, depth string
allSnapshots, orphans bool
concurrency int
bytesPerSec int64
timeout time.Duration
)
fs.StringVar(&volumeID, "volume", "", "volume id")
fs.StringVar(&volumeID, "volume", "", "volume name with --master, or an explicit <name>-<id8> store directory")
fs.StringVar(&master, "master", "", "blockmaster gRPC address (resolves --volume name to its full layout identity)")
fs.StringVar(&filer, "chunk-filer", "", "SeaweedFS filer gRPC address host:port")
fs.StringVar(&base, "chunk-path", defaultChunkPathCLI, "filer directory holding one directory per volume")
fs.StringVar(&snapshot, "snapshot", "", "accepted for compatibility: every snapshot HEAD names is always checked")
@@ -75,6 +76,15 @@ func chunkVerify(args []string, stdout, stderr io.Writer) int {
// false findings, so it runs the check.
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
dir := volumeID
opts := layout.VerifyOptions{Depth: d, Orphans: orphans}
if master != "" {
id, err := resolveVolumeID(ctx, master, volumeID)
if err != nil {
return verifyIncomplete(layout.VerifyResult{}, err, stdout, stderr)
}
dir, opts.ExpectedID = layout.VolumeDir(volumeID, id), id
}
f, closeFn, err := dialChunkFiler(filer)
if err != nil {
return usage(err.Error())
@@ -83,10 +93,13 @@ func chunkVerify(args []string, stdout, stderr io.Writer) int {
if exit := refuseUnlessSingleFiler("verify", f, timeout, stdout, stderr); exit >= 0 {
return exit
}
res, err := chunkstore.VerifyLayout(ctx, f, base, volumeID, layout.VerifyOptions{Depth: d, Orphans: orphans})
res, err := chunkstore.VerifyLayout(ctx, f, base, dir, opts)
if err != nil {
return verifyIncomplete(res, err, stdout, stderr)
}
if master == "" && res.Incomplete == "no VOLUME" {
return usage("no VOLUME in the supplied directory: give --master to resolve a name, or the <name>-<id8> store directory")
}
out, err := verifyJSON(res)
if err != nil {
fmt.Fprintf(stderr, "sw-block ops chunk verify: %v\n", err)
@@ -0,0 +1,53 @@
package main
import (
"context"
"strings"
"testing"
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
)
func TestOpsChunk_VerifyProductionLayoutNameAndDirectory(t *testing.T) {
store := newMemChunkStore()
useMemChunkStore(t, store)
v := cliVolume(t, store, "verify-prod", "s")
for i, args := range [][]string{
cliArgs("verify", volArgs("volume", v), []string{"--depth", "data", "--timeout", "5s", "--orphans"}),
{"verify", "--volume", v.Dir(), "--chunk-filer", "filer:18888", "--depth", "data", "--timeout", "5s", "--orphans"},
} {
code, out, errs := runChunk(args...)
res := decodeVerify(t, out)
if res.MasterIdentityChecked != (i == 0) {
t.Fatalf("master identity disclosure: %s", out)
}
if code != 0 || !res.Complete || !res.OrphansChecked || len(res.Findings) != 0 || res.Chunks != 1 {
t.Fatalf("%v: exit%d out=%s err=%s", args, code, out, errs)
}
}
}
func TestOpsChunk_VerifyBindsMasterFullIDDespiteDirectoryPrefixCollision(t *testing.T) {
store := newMemChunkStore()
useMemChunkStore(t, store)
v := cliVolume(t, store, "verify-collision", "s")
want := v.ID
want[15] ^= 1
if layout.VolumeDir(v.Name, want) != v.Dir() {
t.Fatal("test ids do not collide on id8")
}
resolveVolumeID = func(context.Context, string, string) (layout.VolumeID, error) { return want, nil }
code, out, errs := runChunk(cliArgs("verify", volArgs("volume", v))...)
res := decodeVerify(t, out)
if code != 1 || res.Complete || len(res.Findings) != 1 || res.Findings[0].Class != layout.FindIdentity {
t.Fatalf("wrong full identity: %d %s %s", code, out, errs)
}
}
func TestOpsChunk_VerifyLegacyNameNeedsResolution(t *testing.T) {
verifyCLIFixture(t)
code, out, errs := runChunk("verify", "--volume", "v1", "--chunk-filer", "filer:18888")
if code != 2 || strings.Contains(out, "MISSING") || !strings.Contains(out+errs, "--master") || !strings.Contains(out+errs, "<name>-<id8>") {
t.Fatalf("legacy name: %d %s %s", code, out, errs)
}
}
+18 -14
View File
@@ -27,7 +27,7 @@ func verifyCLIFixture(t *testing.T) (*manifestFixtureFiler, string) {
return mem, func() error { return nil }, nil
}
t.Cleanup(func() { dialChunkFiler = prev })
root := path.Join(defaultChunkPathCLI, "v1")
var root string
put := func(rel string, b []byte) {
p := path.Join(root, rel)
if err := mem.CreateEntry(ctx, path.Dir(p), &filerpb.Entry{Name: path.Base(p), Content: b}, true); err != nil {
@@ -38,6 +38,10 @@ func verifyCLIFixture(t *testing.T) (*manifestFixtureFiler, string) {
if err != nil {
t.Fatal(err)
}
root = path.Join(defaultChunkPathCLI, layout.VolumeDir("v1", id))
oldResolve := resolveVolumeID
resolveVolumeID = func(context.Context, string, string) (layout.VolumeID, error) { return id, nil }
t.Cleanup(func() { resolveVolumeID = oldResolve })
vb, err := layout.Volume{ID: id, Name: "v1", Geometry: layout.Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4 * 4096}, Format: layout.VolumeFormat}.Encode()
if err != nil {
t.Fatal(err)
@@ -85,7 +89,7 @@ func decodeVerify(t *testing.T, out string) layout.VerifyResult {
// complete, 2 usage; the result is one JSON object with one finding per line.
func TestOpsChunk_VerifyExitCodes(t *testing.T) {
mem, chunk1 := verifyCLIFixture(t)
filer := []string{"--volume", "v1", "--chunk-filer", "filer:18888"}
filer := []string{"--volume", "v1", "--master", "m:1", "--chunk-filer", "filer:18888"}
code, out, errs := runChunk(append([]string{"verify"}, filer...)...)
res := decodeVerify(t, out)
@@ -113,28 +117,28 @@ func TestOpsChunk_VerifyExitCodes(t *testing.T) {
}
// Could not complete: a volume without VOLUME/HEAD.
code, out, errs = runChunk("verify", "--volume", "nope", "--chunk-filer", "filer:18888")
code, out, errs = runChunk("verify", "--volume", "nope", "--master", "m:1", "--chunk-filer", "filer:18888")
if res = decodeVerify(t, out); code != chunkExitFailed || res.Complete || !strings.Contains(errs, "incomplete") {
t.Fatalf("verify of a missing volume: %d %q %q", code, out, errs)
}
for _, args := range [][]string{
{"verify", "--chunk-filer", "f:1"}, // no volume
{"verify", "--volume", "v1"}, // no filer
{"verify", "--volume", "v1", "--chunk-filer", "f:1", "--depth", "all"}, // bad depth
{"verify", "--volume", "v1", "--chunk-filer", "f:1", "--depth", "data"}, // data without --timeout
{"verify", "--volume", "v1", "--chunk-filer", "f:1", "--snapshot", "s1", "--all-snapshots"},
{"verify", "--volume", "v1", "--chunk-filer", "f:1", "--concurrency", "0"},
{"verify", "--volume", "v1", "--chunk-filer", "f:1", "--bytes-per-sec", "-1"},
{"verify", "--volume", "v1", "--chunk-filer", "f:1", "extra"},
{"verify", "--volume", "v1", "--chunk-filer", "f:1", "--bogus"},
{"verify", "--chunk-filer", "f:1"}, // no volume
{"verify", "--volume", "v1", "--master", "m:1"}, // no filer
{"verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "--depth", "all"}, // bad depth
{"verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "--depth", "data"}, // data without --timeout
{"verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "--snapshot", "s1", "--all-snapshots"},
{"verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "--concurrency", "0"},
{"verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "--bytes-per-sec", "-1"},
{"verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "extra"},
{"verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "--bogus"},
} {
code, out, _ := runChunk(args...)
if code != 2 || chunkErrorOut(t, out).Code != codeBadRequestCLI {
t.Fatalf("%v: exit %d %q; want 2 and bad_request", args, code, out)
}
}
if code, out, _ := runChunk("verify", "--volume", "v1", "--chunk-filer", "f:1", "--depth", "data"); !strings.Contains(out, "--timeout") {
if code, out, _ := runChunk("verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "f:1", "--depth", "data"); !strings.Contains(out, "--timeout") {
t.Fatalf("data without --timeout: %d %q; want the reason", code, out)
}
}
@@ -161,7 +165,7 @@ func TestOpsChunk_VerifyReadErrorIsIncomplete(t *testing.T) {
dialChunkFiler = func(string) (chunkstore.Filer, func() error, error) {
return store, func() error { return nil }, nil
}
code, out, errs := runChunk("verify", "--volume", "v1", "--chunk-filer", "filer:18888", "--depth", "data", "--timeout", "10s")
code, out, errs := runChunk("verify", "--volume", "v1", "--master", "m:1", "--chunk-filer", "filer:18888", "--depth", "data", "--timeout", "10s")
if code != chunkExitFailed || !strings.Contains(out, "503") || !strings.Contains(errs, "incomplete") {
t.Fatalf("verify with an unreadable chunk: %d %q %q", code, out, errs)
}
@@ -19,6 +19,12 @@ import (
// master's volume record, never from a name given plus an id read from
// that same directory. A new site fails until it is classified here.
var deleteSites = map[string]string{
"cmd/sw-block/chunk_verify.go chunkVerify -> VolumeDir": "master-resolved full id and requested name; offline form accepts an explicit directory without discovering an identity",
"core/frontend/chunkstore/layout/verify.go verifier.chunks -> VolumeDir": "chunk reference's owner name and full id",
"core/frontend/chunkstore/layout/verify.go verifier.depHead -> VolumeDir": "HEAD dependent target name and full id",
"core/frontend/chunkstore/layout/verify.go verifier.orphans -> VolumeDir": "HEAD dependent target name and full id",
"core/frontend/chunkstore/layout/verify.go verifier.volumeID -> VolumeDir": "validation only: compare inspected VOLUME name/id with the already selected directory, never choose a different directory",
"cmd/blockvolume/main.go parseFlags -> VolumeDir": "validated master layout id and volume name; TestBlockvolumeLayoutIdentitySelectsTheLocalRoot",
"core/launcher/k8s_renderer.go durableRoot -> VolumeDir": "persisted workload plan layout id and name; launcher layout identity controls",
@@ -14,7 +14,7 @@ func TestEachRefAndHeadRoots(t *testing.T) {
ctx := context.Background()
m := &memStore{obj: map[string][]byte{}}
rn := putImage(t, m, "v", map[uint64]string{0: "a", 1: "b", ShardSize + 2: "c"}, nil)
r, err := NewReader(vbase, "v", m.fetch)
r, err := NewReader(vbase, VolumeDir("v", vid("v", 0)), m.fetch)
if err != nil {
t.Fatal(err)
}
@@ -40,12 +40,12 @@ func TestEachRefAndHeadRoots(t *testing.T) {
t.Fatal(err)
}
seg := img.root.Segments[0]
m.readErr = path.Join(vbase, "v", seg.Path())
m.readErr = path.Join(vbase, VolumeDir("v", vid("v", 0)), seg.Path())
if _, err := visit(AllShards, -1); err == nil || errors.Is(err, ErrMissing) {
t.Fatalf("unreadable segment: %v; want the read error", err)
}
m.readErr = ""
delete(m.obj, path.Join(vbase, "v", seg.Path()))
delete(m.obj, path.Join(vbase, VolumeDir("v", vid("v", 0)), seg.Path()))
if _, err := visit(AllShards, -1); !errors.Is(err, ErrMissing) {
t.Fatalf("missing segment: %v; want ErrMissing", err)
}
@@ -36,9 +36,10 @@ type List func(ctx context.Context, p string) ([]string, error)
// VerifyOptions configures one pass.
type VerifyOptions struct {
Depth string // DepthNames (default) or DepthFull
Orphans bool // also report unreachable own names (needs List)
List List
ExpectedID VolumeID // optional full identity resolved by the master; zero for explicit directory inspection
Depth string // DepthNames (default) or DepthFull
Orphans bool // also report unreachable own names (needs List)
List List
}
// Finding is one problem found at Path (relative to <base>).
@@ -49,12 +50,13 @@ type Finding struct {
// VerifyResult is one pass. Complete is false when the pass could not read
// what it needed; Incomplete says why. Findings are sorted by path.
type VerifyResult struct {
Complete bool
Incomplete string
Roots, Segments int
Chunks, ChunksZero int
OrphansChecked bool
Findings []Finding
Complete bool
Incomplete string
Roots, Segments int
Chunks, ChunksZero int
OrphansChecked bool
MasterIdentityChecked bool // full VOLUME id matched a master-resolved ExpectedID
Findings []Finding
}
type verifier struct {
@@ -65,6 +67,7 @@ type verifier struct {
ownPool map[string]bool // reachable own names, by path relative to the volume
ownMeta map[string]bool
owners map[string]ownerID // VOLUME id per chunk owner, read once
ownID VolumeID
}
type ownerID struct {
@@ -72,7 +75,8 @@ type ownerID struct {
ok bool
}
// Verify checks vol under base; see the top of this file.
// Verify checks the canonical store directory vol under base; callers resolve
// logical names through the master before choosing VolumeDir(name, id).
func Verify(ctx context.Context, base, vol string, fetch Fetch, opts VerifyOptions) (VerifyResult, error) {
if err := checkOwner(vol); err != nil {
return VerifyResult{}, err
@@ -96,6 +100,8 @@ func Verify(ctx context.Context, base, vol string, fetch Fetch, opts VerifyOptio
return VerifyResult{}, err
}
if ok {
v.ownID = head.VolumeID
v.res.MasterIdentityChecked = !opts.ExpectedID.IsZero()
for _, rn := range HeadRoots(head) {
if err := v.root(ctx, vol, rn, true); err != nil {
return VerifyResult{}, err
@@ -171,9 +177,25 @@ func (v *verifier) volumeID(ctx context.Context, vol string, report bool) (Volum
if report {
v.find(FindMalformed, p, err.Error())
v.incomplete("VOLUME does not decode")
} else {
v.incomplete("dependent VOLUME does not decode: orphans not reported")
}
return VolumeID{}, false, nil
}
if vol != VolumeDir(rec.Name, rec.ID) {
if report {
v.find(FindIdentity, p, "VOLUME name/id do not match its store directory")
v.incomplete("VOLUME directory identity mismatch")
} else {
v.incomplete("dependent VOLUME directory identity mismatch: orphans not reported")
}
return VolumeID{}, false, nil
}
if report && !v.opts.ExpectedID.IsZero() && rec.ID != v.opts.ExpectedID {
v.find(FindIdentity, p, "VOLUME id differs from the master's resolved layout id")
v.incomplete("VOLUME identity mismatch")
return VolumeID{}, false, nil
}
return rec.ID, true, nil
}
@@ -277,29 +299,30 @@ func (v *verifier) chunks(ctx context.Context, r *Reader, seg Segment, count boo
sort.Slice(idx, func(i, j int) bool { return idx[i] < idx[j] })
for _, i := range idx {
ref := seg.Chunks[i]
if ref.Owner == v.vol {
if ref.OwnerID == v.ownID {
v.ownPool[ref.Chunk.Path()] = true
}
if !count {
continue
}
v.res.Chunks++
p := path.Join(ref.Owner, ref.Chunk.Path())
o, seen := v.owners[ref.Owner]
dir := VolumeDir(ref.Owner, ref.OwnerID)
p := path.Join(dir, ref.Chunk.Path())
o, seen := v.owners[dir]
if !seen {
id, ok, err := v.volumeID(ctx, ref.Owner, false)
id, ok, err := v.volumeID(ctx, dir, false)
if err != nil {
return err
}
o = ownerID{id, ok}
v.owners[ref.Owner] = o
v.owners[dir] = o
}
if !o.ok || o.id != ref.OwnerID {
v.find(FindIdentity, p, fmt.Sprintf("names owner %s id %s; its VOLUME has %s", ref.Owner, ref.OwnerID, map[bool]string{true: o.id.String(), false: "none"}[o.ok]))
continue
}
if v.opts.Depth == DepthFull {
if _, err := r.get(ctx, ref.Owner, ref.Chunk.Path(), ref.Chunk.Hash); err != nil {
if _, err := r.get(ctx, dir, ref.Chunk.Path(), ref.Chunk.Hash); err != nil {
if err := v.classify(p, err); err != nil {
return err
}
@@ -342,7 +365,7 @@ func (v *verifier) orphans(ctx context.Context, h Head) error {
continue
}
for _, rn := range HeadRoots(dh) {
if err := v.root(ctx, d, rn, false); err != nil {
if err := v.root(ctx, VolumeDir(d, deps[d]), rn, false); err != nil {
return err
}
}
@@ -400,13 +423,14 @@ func (v *verifier) depHead(ctx context.Context, d string, want VolumeID) (Head,
if checkOwner(d) != nil {
return Head{}, false, nil
}
id, ok, err := v.volumeID(ctx, d, false)
dir := VolumeDir(d, want)
id, ok, err := v.volumeID(ctx, dir, false)
if err != nil || !ok || id != want {
return Head{}, false, err
}
b, ok, err := v.fetch(ctx, path.Join(v.base, d, HeadName))
b, ok, err := v.fetch(ctx, path.Join(v.base, dir, HeadName))
if err != nil {
return Head{}, false, fmt.Errorf("layout: read %s: %w", path.Join(d, HeadName), err)
return Head{}, false, fmt.Errorf("layout: read %s: %w", path.Join(dir, HeadName), err)
}
h, derr := DecodeHead(b, 0, id)
if !ok || derr != nil {
@@ -46,7 +46,7 @@ func putImage(t *testing.T, m *memStore, vol string, data map[uint64]string, bor
manifest := map[uint64]Ref{}
for i, d := range data {
c := NameChunk(i, []byte(d))
m.obj[path.Join(vbase, vol, c.Path())] = []byte(d)
m.obj[path.Join(vbase, VolumeDir(vol, vid(vol, 0)), c.Path())] = []byte(d)
manifest[i] = Ref{Owner: vol, OwnerID: vid(vol, 0), Chunk: c}
}
for i, r := range borrowed {
@@ -57,13 +57,13 @@ func putImage(t *testing.T, m *memStore, vol string, data map[uint64]string, bor
t.Fatal(err)
}
for n, b := range segs {
m.obj[path.Join(vbase, vol, n.Path())] = b
m.obj[path.Join(vbase, VolumeDir(vol, vid(vol, 0)), n.Path())] = b
}
rn, rb, err := NameRoot(root)
if err != nil {
t.Fatal(err)
}
m.obj[path.Join(vbase, vol, rn.Path())] = rb
m.obj[path.Join(vbase, VolumeDir(vol, vid(vol, 0)), rn.Path())] = rb
return rn
}
@@ -81,7 +81,7 @@ func vputVolume(t *testing.T, m *memStore, vol string, id VolumeID) {
if err != nil {
t.Fatal(err)
}
m.obj[path.Join(vbase, vol, VolumeName)] = b
m.obj[path.Join(vbase, VolumeDir(vol, id), VolumeName)] = b
}
func putHead(t *testing.T, m *memStore, vol string, cur *RootName, snaps map[string]Snapshot) {
@@ -92,7 +92,7 @@ func putHead(t *testing.T, m *memStore, vol string, cur *RootName, snaps map[str
if err != nil {
t.Fatal(err)
}
m.obj[path.Join(vbase, vol, HeadName)] = b
m.obj[path.Join(vbase, VolumeDir(vol, vid(vol, 0)), HeadName)] = b
}
func newVol(t *testing.T) (*memStore, RootName) {
@@ -105,7 +105,7 @@ func newVol(t *testing.T) (*memStore, RootName) {
func run(t *testing.T, m *memStore, opts VerifyOptions) VerifyResult {
t.Helper()
opts.List = m.list
r, err := Verify(context.Background(), vbase, "v1", m.fetch, opts)
r, err := Verify(context.Background(), vbase, VolumeDir("v1", vid("v1", 0)), m.fetch, opts)
if err != nil {
t.Fatal(err)
}
@@ -129,7 +129,7 @@ func TestVerifyCleanVolume(t *testing.T) {
}
func chunkPath(i uint64, d string) string {
return path.Join(vbase, "v1", NameChunk(i, []byte(d)).Path())
return path.Join(vbase, VolumeDir("v1", vid("v1", 0)), NameChunk(i, []byte(d)).Path())
}
func TestVerifyFindsMissingAndCorrupt(t *testing.T) {
@@ -137,18 +137,18 @@ func TestVerifyFindsMissingAndCorrupt(t *testing.T) {
delete(m.obj, chunkPath(7, "bbbb"))
m.obj[chunkPath(0, "aaaa")] = []byte("XXXX")
r := run(t, m, VerifyOptions{Depth: DepthFull})
if c := classes(r); !strings.Contains(c, "MISSING v1/pool/0/7-") || !strings.Contains(c, "CORRUPT v1/pool/0/0-") || len(r.Findings) != 2 {
if c := classes(r); !strings.Contains(c, "MISSING v1-76310000/pool/0/7-") || !strings.Contains(c, "CORRUPT v1-76310000/pool/0/0-") || len(r.Findings) != 2 {
t.Fatalf("full depth: %s", c)
}
// names depth: presence only, by design (the bytes are not read)
r = run(t, m, VerifyOptions{Depth: DepthNames})
if c := classes(r); !strings.Contains(c, "MISSING v1/pool/0/7-") || strings.Contains(c, "CORRUPT") {
if c := classes(r); !strings.Contains(c, "MISSING v1-76310000/pool/0/7-") || strings.Contains(c, "CORRUPT") {
t.Fatalf("names depth: %s", c)
}
// a corrupt root and a missing segment
m2, rn2 := newVol(t)
m2.obj[path.Join(vbase, "v1", rn2.Path())] = []byte("not a root")
if c := classes(run(t, m2, VerifyOptions{})); !strings.Contains(c, "CORRUPT v1/root/") {
m2.obj[path.Join(vbase, VolumeDir("v1", vid("v1", 0)), rn2.Path())] = []byte("not a root")
if c := classes(run(t, m2, VerifyOptions{})); !strings.Contains(c, "CORRUPT v1-76310000/root/") {
t.Fatalf("corrupt root: %s", c)
}
m3, _ := newVol(t)
@@ -157,7 +157,7 @@ func TestVerifyFindsMissingAndCorrupt(t *testing.T) {
delete(m3.obj, p)
}
}
if c := classes(run(t, m3, VerifyOptions{})); !strings.Contains(c, "MISSING v1/seg/1-") {
if c := classes(run(t, m3, VerifyOptions{})); !strings.Contains(c, "MISSING v1-76310000/seg/1-") {
t.Fatalf("missing segment: %s", c)
}
_ = rn
@@ -165,13 +165,13 @@ func TestVerifyFindsMissingAndCorrupt(t *testing.T) {
func TestVerifyHeadMissingOrMalformedIsIncomplete(t *testing.T) {
m, _ := newVol(t)
delete(m.obj, path.Join(vbase, "v1", HeadName))
delete(m.obj, path.Join(vbase, VolumeDir("v1", vid("v1", 0)), HeadName))
r := run(t, m, VerifyOptions{Orphans: true})
if r.Complete || classes(r) != "MISSING v1/HEAD" || r.OrphansChecked {
if r.Complete || classes(r) != "MISSING v1-76310000/HEAD" || r.OrphansChecked {
t.Fatalf("no HEAD: %+v", r)
}
m.obj[path.Join(vbase, "v1", HeadName)] = []byte("{")
if r = run(t, m, VerifyOptions{}); r.Complete || !strings.HasPrefix(classes(r), "MALFORMED v1/HEAD") {
m.obj[path.Join(vbase, VolumeDir("v1", vid("v1", 0)), HeadName)] = []byte("{")
if r = run(t, m, VerifyOptions{}); r.Complete || !strings.HasPrefix(classes(r), "MALFORMED v1-76310000/HEAD") {
t.Fatalf("bad HEAD: %+v", r)
}
}
@@ -184,7 +184,7 @@ func TestVerifyWalksSnapshotRoots(t *testing.T) {
t.Fatalf("with snapshot: %+v", r)
}
delete(m.obj, chunkPath(2, "ssss"))
if c := classes(run(t, m, VerifyOptions{})); c != "MISSING v1/pool/0/"+NameChunk(2, []byte("ssss")).String() {
if c := classes(run(t, m, VerifyOptions{})); c != "MISSING v1-76310000/pool/0/"+NameChunk(2, []byte("ssss")).String() {
t.Fatalf("snapshot-only chunk: %s", c)
}
}
@@ -192,10 +192,10 @@ func TestVerifyWalksSnapshotRoots(t *testing.T) {
func TestVerifyOrphans(t *testing.T) {
m, _ := newVol(t)
extra := NameChunk(9, []byte("zzzz"))
m.obj[path.Join(vbase, "v1", extra.Path())] = []byte("zzzz")
m.obj[path.Join(vbase, "v1", SegDir, "garbage")] = []byte("x")
m.obj[path.Join(vbase, VolumeDir("v1", vid("v1", 0)), extra.Path())] = []byte("zzzz")
m.obj[path.Join(vbase, VolumeDir("v1", vid("v1", 0)), SegDir, "garbage")] = []byte("x")
r := run(t, m, VerifyOptions{Orphans: true})
if c := classes(r); c != "ORPHAN v1/"+extra.Path()+"; MALFORMED v1/seg/garbage" && c != "MALFORMED v1/seg/garbage; ORPHAN v1/"+extra.Path() {
if c := classes(r); c != "ORPHAN v1-76310000/"+extra.Path()+"; MALFORMED v1-76310000/seg/garbage" && c != "MALFORMED v1-76310000/seg/garbage; ORPHAN v1-76310000/"+extra.Path() {
t.Fatalf("orphans: %s", c)
}
if r = run(t, m, VerifyOptions{}); len(r.Findings) != 0 || r.OrphansChecked {
@@ -209,33 +209,93 @@ func TestVerifyDependentReachIsNotOrphanAndUnreadableDependentSuppresses(t *test
snap := putImage(t, m, "v1", map[uint64]string{4: "dddd"}, nil)
putHead(t, m, "v1", &cur, map[string]Snapshot{"s1": {Root: snap, Dependents: []Dependent{{Target: "v2", TargetID: vid("v2", 0), Root: snap}}}})
borrowed := NameChunk(5, []byte("eeee"))
m.obj[path.Join(vbase, "v1", borrowed.Path())] = []byte("eeee") // only v2 names it
m.obj[path.Join(vbase, VolumeDir("v1", vid("v1", 0)), borrowed.Path())] = []byte("eeee") // only v2 names it
v2 := putImage(t, m, "v2", nil, map[uint64]Ref{5: {Owner: "v1", OwnerID: vid("v1", 0), Chunk: borrowed}})
putHead(t, m, "v2", &v2, nil)
if r := run(t, m, VerifyOptions{Orphans: true}); !r.Complete || len(r.Findings) != 0 || !r.OrphansChecked {
t.Fatalf("a chunk only the dependent names is not an orphan: %+v", r)
}
head2 := m.obj[path.Join(vbase, "v2", HeadName)]
delete(m.obj, path.Join(vbase, "v2", HeadName))
head2 := m.obj[path.Join(vbase, VolumeDir("v2", vid("v2", 0)), HeadName)]
delete(m.obj, path.Join(vbase, VolumeDir("v2", vid("v2", 0)), HeadName))
if r := run(t, m, VerifyOptions{Orphans: true}); r.Complete || r.OrphansChecked || len(r.Findings) != 0 {
t.Fatalf("an unreadable dependent must suppress orphans: %+v", r)
}
// v2 created again under the same name (new id): no longer a dependent, so the borrowed chunk is an orphan
m.obj[path.Join(vbase, "v2", HeadName)] = head2
m.obj[path.Join(vbase, VolumeDir("v2", vid("v2", 0)), HeadName)] = head2
vputVolume(t, m, "v2", vid("v2", 1))
if r := run(t, m, VerifyOptions{Orphans: true}); !r.Complete || classes(r) != "ORPHAN v1/"+borrowed.Path() {
if r := run(t, m, VerifyOptions{Orphans: true}); !r.Complete || classes(r) != "ORPHAN v1-76310000/"+borrowed.Path() {
t.Fatalf("a re-created target matches no dependent: %+v", r)
}
}
func TestVerifyDependentUncertainIdentitySuppressesOrphans(t *testing.T) {
for _, fault := range []string{"wrong-name", "malformed-volume", "head-read", "root-read"} {
t.Run(fault, func(t *testing.T) {
m, cur := newVol(t)
snap := putImage(t, m, "v1", map[uint64]string{4: "dddd"}, nil)
putHead(t, m, "v1", &cur, map[string]Snapshot{"s": {Root: snap, Dependents: []Dependent{{Target: "v2", TargetID: vid("v2", 0), Root: snap}}}})
borrowed := NameChunk(5, []byte("eeee"))
m.obj[path.Join(vbase, VolumeDir("v1", vid("v1", 0)), borrowed.Path())] = []byte("eeee")
root := putImage(t, m, "v2", nil, map[uint64]Ref{5: {Owner: "v1", OwnerID: vid("v1", 0), Chunk: borrowed}})
putHead(t, m, "v2", &root, nil)
dir := path.Join(vbase, VolumeDir("v2", vid("v2", 0)))
switch fault {
case "wrong-name":
rec, err := DecodeVolume(m.obj[path.Join(dir, VolumeName)])
if err != nil {
t.Fatal(err)
}
rec.Name = "other"
raw, err := rec.Encode()
if err != nil {
t.Fatal(err)
}
m.obj[path.Join(dir, VolumeName)] = raw
case "malformed-volume":
m.obj[path.Join(dir, VolumeName)] = []byte("{")
case "head-read":
m.readErr = path.Join(dir, HeadName)
case "root-read":
m.readErr = path.Join(dir, root.Path())
}
r, err := Verify(context.Background(), vbase, VolumeDir("v1", vid("v1", 0)), m.fetch, VerifyOptions{Orphans: true, List: m.list})
if (err == nil && r.Complete) || r.OrphansChecked {
t.Fatalf("uncertain dependent: %+v %v", r, err)
}
for _, f := range r.Findings {
if f.Class == FindOrphan {
t.Fatalf("uncertainty is not an orphan proof: %+v", r)
}
}
})
}
}
func TestVerifyMisplacedVolumeIsIncomplete(t *testing.T) {
m, _ := newVol(t)
p := path.Join(vbase, VolumeDir("v1", vid("v1", 0)), VolumeName)
rec, err := DecodeVolume(m.obj[p])
if err != nil {
t.Fatal(err)
}
rec.Name = "other"
m.obj[p], err = rec.Encode()
if err != nil {
t.Fatal(err)
}
r := run(t, m, VerifyOptions{Orphans: true})
if r.Complete || r.OrphansChecked || classes(r) != "IDENTITY v1-76310000/VOLUME" {
t.Fatalf("misplaced VOLUME: %+v", r)
}
}
func TestVerifyVolumeRecordAndHeadID(t *testing.T) {
m, _ := newVol(t)
delete(m.obj, path.Join(vbase, "v1", VolumeName))
if r := run(t, m, VerifyOptions{}); r.Complete || classes(r) != "MISSING v1/VOLUME" {
delete(m.obj, path.Join(vbase, VolumeDir("v1", vid("v1", 0)), VolumeName))
if r := run(t, m, VerifyOptions{}); r.Complete || classes(r) != "MISSING v1-76310000/VOLUME" {
t.Fatalf("no VOLUME: %+v", r)
}
vputVolume(t, m, "v1", vid("v1", 9)) // a VOLUME of another id: HEAD names v1's first id
if r := run(t, m, VerifyOptions{}); r.Complete || !strings.HasPrefix(classes(r), "MALFORMED v1/HEAD") {
if r := run(t, m, VerifyOptions{}); r.Complete || !strings.HasPrefix(classes(r), "MALFORMED v1-76310000/HEAD") {
t.Fatalf("HEAD of another volume id: %+v", r)
}
}
@@ -247,12 +307,12 @@ func TestVerifyChunkOwnerIdentity(t *testing.T) {
snap := putImage(t, m2, "v1", nil, map[uint64]Ref{4: {Owner: "v3", OwnerID: vid("v3", 0), Chunk: NameChunk(4, []byte("gggg"))}})
cur := putImage(t, m2, "v1", map[uint64]string{0: "aaaa"}, nil)
putHead(t, m2, "v1", &cur, map[string]Snapshot{"s1": {Root: snap}})
m2.obj[path.Join(vbase, "v3", NameChunk(4, []byte("gggg")).Path())] = []byte("gggg") // v3 has no VOLUME
if c := classes(run(t, m2, VerifyOptions{Depth: DepthFull})); !strings.HasPrefix(c, "IDENTITY v3/pool/0/4-") {
m2.obj[path.Join(vbase, VolumeDir("v3", vid("v3", 0)), NameChunk(4, []byte("gggg")).Path())] = []byte("gggg") // v3 has no VOLUME
if c := classes(run(t, m2, VerifyOptions{Depth: DepthFull})); !strings.HasPrefix(c, "IDENTITY v3-76330000/pool/0/4-") {
t.Fatalf("a chunk of an owner without VOLUME: %s", c)
}
vputVolume(t, m2, "v3", vid("v3", 1)) // an owner VOLUME of another id
if c := classes(run(t, m2, VerifyOptions{Depth: DepthFull})); !strings.HasPrefix(c, "IDENTITY v3/pool/0/4-") {
if c := classes(run(t, m2, VerifyOptions{Depth: DepthFull})); !strings.HasPrefix(c, "IDENTITY v3-76330000/pool/0/4-") {
t.Fatalf("a chunk of an owner with another id: %s", c)
}
vputVolume(t, m2, "v3", vid("v3", 0))
@@ -265,7 +325,7 @@ func TestVerifyChunkOwnerIdentity(t *testing.T) {
func TestVerifyReadErrorIsReturned(t *testing.T) {
m, _ := newVol(t)
m.readErr = chunkPath(7, "bbbb")
if _, err := Verify(context.Background(), vbase, "v1", m.fetch, VerifyOptions{}); err == nil {
if _, err := Verify(context.Background(), vbase, VolumeDir("v1", vid("v1", 0)), m.fetch, VerifyOptions{}); err == nil {
t.Fatal("a read failure must be returned, not judged")
}
}
@@ -35,7 +35,8 @@ func (s *LayoutStore) List(ctx context.Context, p string) ([]string, error) {
}
}
// VerifyLayout runs layout.Verify for vol under base through this adapter's
// VerifyLayout runs layout.Verify for the canonical store directory vol under
// base (VolumeDir(name, id), not a logical volume name) through this adapter's
// Fetch and List (read-only; neither uses the volume id, which the pass
// reads from VOLUME itself). f must also serve blobs, as the SWFS client does.
func VerifyLayout(ctx context.Context, f Filer, base, vol string, opts layout.VerifyOptions) (layout.VerifyResult, error) {
@@ -44,13 +44,13 @@ func verifyFixtureVolume(t *testing.T) (filerBlobs, layout.VolumeID) {
if err != nil {
t.Fatal(err)
}
putFile(t, f, "/blocks/v/"+layout.VolumeName, vb)
putFile(t, f, path.Join("/blocks", layout.VolumeDir("v", id))+"/"+layout.VolumeName, vb)
manifest := map[uint64]layout.Ref{}
putDir(t, f, "/blocks/v/pool/0")
putDir(t, f, path.Join("/blocks", layout.VolumeDir("v", id), "pool/0"))
for _, i := range []uint64{0, 5} {
d := []byte(strings.Repeat(string(rune('a'+i)), 64))
c := layout.NameChunk(i, d)
putFile(t, f, path.Join("/blocks/v", c.Path()), d)
putFile(t, f, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), c.Path()), d)
manifest[i] = layout.Ref{Owner: "v", OwnerID: id, Chunk: c}
}
root, segs, err := layout.Build(manifest)
@@ -58,26 +58,26 @@ func verifyFixtureVolume(t *testing.T) (filerBlobs, layout.VolumeID) {
t.Fatal(err)
}
for n, sb := range segs {
putFile(t, f, path.Join("/blocks/v", n.Path()), sb)
putFile(t, f, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), n.Path()), sb)
}
rn, rb, err := layout.NameRoot(root)
if err != nil {
t.Fatal(err)
}
putFile(t, f, path.Join("/blocks/v", rn.Path()), rb)
putFile(t, f, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), rn.Path()), rb)
hb, err := layout.Head{VolumeID: id, Epoch: 1, Holder: "s/r", ClaimID: "c", Activity: layout.Activity{Kind: layout.ActIdle}, Current: &rn}.Encode()
if err != nil {
t.Fatal(err)
}
putFile(t, f, "/blocks/v/"+layout.HeadName, hb)
putFile(t, f, path.Join("/blocks", layout.VolumeDir("v", id))+"/"+layout.HeadName, hb)
return filerBlobs{f, b}, id
}
func TestVerifyLayoutThroughTheAdapter(t *testing.T) {
fb, _ := verifyFixtureVolume(t)
fb, id := verifyFixtureVolume(t)
ctx := context.Background()
before := snapshotStore(fb)
r, err := VerifyLayout(ctx, fb, "/blocks", "v", layout.VerifyOptions{Depth: layout.DepthFull, Orphans: true})
r, err := VerifyLayout(ctx, fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: layout.DepthFull, Orphans: true})
if err != nil || !r.Complete || len(r.Findings) != 0 || r.Chunks != 2 || !r.OrphansChecked {
t.Fatalf("clean: %+v %v", r, err)
}
@@ -85,38 +85,42 @@ func TestVerifyLayoutThroughTheAdapter(t *testing.T) {
t.Fatalf("verify changed the store:\nbefore %s\nafter %s", before, after)
}
extra := layout.NameChunk(9, []byte("zz"))
putFile(t, fb.fakeFiler, path.Join("/blocks/v", extra.Path()), []byte("zz"))
putFile(t, fb.fakeFiler, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), extra.Path()), []byte("zz"))
c0 := layout.NameChunk(0, []byte(strings.Repeat("a", 64)))
delete(fb.fakeFiler.entries, path.Join("/blocks/v", c0.Path()))
r, err = VerifyLayout(ctx, fb, "/blocks", "v", layout.VerifyOptions{Orphans: true})
delete(fb.fakeFiler.entries, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), c0.Path()))
before = snapshotStore(fb)
r, err = VerifyLayout(ctx, fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Orphans: true})
if err != nil {
t.Fatal(err)
}
if after := snapshotStore(fb); after != before {
t.Fatalf("verify with findings changed the store: before %s after %s", before, after)
}
got := map[string]string{}
for _, f := range r.Findings {
got[f.Path] = f.Class
}
if got["v/"+c0.Path()] != layout.FindMissing || got["v/"+extra.Path()] != layout.FindOrphan || len(got) != 2 {
if got[layout.VolumeDir("v", id)+"/"+c0.Path()] != layout.FindMissing || got[layout.VolumeDir("v", id)+"/"+extra.Path()] != layout.FindOrphan || len(got) != 2 {
t.Fatalf("findings: %+v", r.Findings)
}
}
func TestLayoutStoreListPagesAndStaysInBase(t *testing.T) {
fb, id := verifyFixtureVolume(t)
s, err := NewLayoutStore(fb.fakeFiler, fb.fakeBlobs, "/blocks/v", id)
s, err := NewLayoutStore(fb.fakeFiler, fb.fakeBlobs, path.Join("/blocks", layout.VolumeDir("v", id)), id)
if err != nil {
t.Fatal(err)
}
for i := 0; i < verifyListPage+3; i++ {
putFile(t, fb.fakeFiler, path.Join("/blocks/v/seg", strings.Repeat("x", 4)+string(rune('A'+i%26))+string(rune('a'+i/26%26))+string(rune('a'+i/676))), []byte("s"))
putFile(t, fb.fakeFiler, path.Join(path.Join("/blocks", layout.VolumeDir("v", id), "seg"), strings.Repeat("x", 4)+string(rune('A'+i%26))+string(rune('a'+i/26%26))+string(rune('a'+i/676))), []byte("s"))
}
names, err := s.List(context.Background(), "/blocks/v/seg")
names, err := s.List(context.Background(), path.Join("/blocks", layout.VolumeDir("v", id), "seg"))
if err != nil {
t.Fatal(err)
}
segs := 0
for n := range fb.fakeFiler.entries {
if path.Dir(n) == "/blocks/v/seg" {
if path.Dir(n) == path.Join("/blocks", layout.VolumeDir("v", id), "seg") {
segs++
}
}
@@ -0,0 +1,37 @@
package chunkstore
import (
"context"
"testing"
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
)
type verifyProductionStore struct {
Filer
Blobs
}
// Use the production creators, not a hand-written name-only directory: a
// restored image borrows the source's chunks while owning copied metadata.
func TestVerifyProductionLayoutCurrentAndRestored(t *testing.T) {
ctx := context.Background()
c, source, _, _ := cleanFixture(t)
target := newRef(t, "restored")
if _, err := c.Restore(ctx, source, "s", target); err != nil {
t.Fatal(err)
}
if _, _, err := cleanVia(ctx, c, source, cleanHolder); err != nil {
t.Fatal(err)
}
for _, v := range []VolumeRef{source, target} {
for _, depth := range []string{layout.DepthNames, layout.DepthFull} {
t.Run(v.Name+"/"+depth, func(t *testing.T) {
res, err := VerifyLayout(ctx, verifyProductionStore{c.f, c.b}, c.base, v.Dir(), layout.VerifyOptions{Depth: depth, Orphans: true})
if err != nil || !res.Complete || !res.OrphansChecked || len(res.Findings) != 0 || res.Chunks != 1 {
t.Fatalf("healthy production volume: %+v %v", res, err)
}
})
}
}
}
+2 -2
View File
@@ -977,8 +977,8 @@ 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, `ORPHAN` is reported only for this volume's own names that no root names and no live restore target names; an unreadable live target suppresses every orphan finding, and verify deletes none. | 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`) | — | ACTIVE |
| `INV-VERIFY-IDENTITY-001` | HEAD is judged against the VOLUME record's id, and a chunk reference whose owner VOLUME holds another id (a volume created again under the name) is an `IDENTITY` finding, not a clean read. | 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`) | — | 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-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`) ; `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`) | — | ACTIVE |
| `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` | ACTIVE |
| `INV-RESTORE-READ-REF-001` | A restore target reads each chunk its HEAD names from the pool of the reference's owner, by the reference alone (no other copy, no name-built path); a chunk missing there is an error on a fresh host, never zeros. | M6 restore target read (no transition) | `core/frontend/chunkstore/layout/read.go` `Reader.ReadRef`; `core/frontend/chunkstore/layout_remote.go` `LayoutRemote.Get` | `TestLayoutRemote_RestoreTargetReadsItsSource` (`core/frontend/chunkstore/layout_restore_read_test.go`) | — | ACTIVE |
+7
View File
@@ -482,6 +482,13 @@ failed over by itself (see
- Read it again later with `sw-block ops workspace lost-range`.
4. Start `blockvolume` on the new node, then reconnect the guest.
## Read-only store verification
Use `sw-block ops chunk verify --master MASTER --volume V --chunk-filer FILER`
to resolve the logical name through blockmaster. To inspect an offline store,
omit `--master` and pass its explicit `<name>-<id8>` directory as `--volume`.
See [verification options and exit codes](standalone-deployment.md#read-only-store-verification).
## Host connect settings
The guest's kernel keeps an NVMe/TCP controller whose target went away and keeps reconnecting to the same address.
@@ -0,0 +1,3 @@
# 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 `<name>-<id8>` 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.
@@ -776,6 +776,7 @@ Space comes back in two steps. Neither is immediate.
# or, in weed shell: volume.list and volume.vacuum -garbageThreshold 0.01
```
### Cut retries and cleaning after a dirty start
Automatic cuts and scheduled snapshots retry at the next scheduling opportunity
@@ -798,6 +799,33 @@ cut reuses only content-named chunks that cleaning left behind. A running cut,
a newer completed cut or staging counter, and an unresolved commit prevent that
discard. The kernel's session exclusion and conditional removal remain authoritative.
### Read-only store verification
Resolve a volume's logical name through blockmaster and check its production
store directory (`<name>-<id8>`):
```sh
sw-block ops chunk verify --master MASTER --volume v1 --chunk-filer FILER --orphans
sw-block ops chunk verify --master MASTER --volume v1 --chunk-filer FILER --depth data --timeout 10m --orphans
```
The JSON field `MasterIdentityChecked` states whether the full VOLUME id was checked against the master. Offline directory inspection reports `false`. A name without `--master` that has no VOLUME in the supplied directory is an argument error, with no store finding.
For offline inspection, omit `--master` and give the explicit store directory
as `--volume v1-01234567`. No name scan or legacy name-only path is used. The
directory must match its VOLUME name/id. With `--master`, the full resolved id
must also match VOLUME; the eight-character directory suffix is not an identity
check. Source and restore-target chunks are checked in their owners' canonical
directories using each reference's full owner id.
Verify is read-only: exit 0 means complete with no findings, 3 means complete
with findings, 1 means incomplete, and 2 means invalid arguments. `--depth data`
checks chunk hashes and requires an explicit timeout. `--orphans` only reports;
it never deletes anything. Master connections use the same TLS environment as
the other `sw-block ops` commands.
### SeaweedFS maintenance commands that destroy chunk volumes
A walstore-chunk volume keeps its data in SeaweedFS as needles that **no file's chunk list names**: the volume's