From 95abcb3183baa17a11b8b544061d42689652012e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 1 Dec 2026 00:42:47 -0800 Subject: [PATCH] fix: verify backing needles with HEAD and retain exact chunk hashes --- seaweed-block/cmd/sw-block/chunk_verify.go | 2 +- .../core/frontend/chunkstore/fake_test.go | 10 +++ .../core/frontend/chunkstore/layout/verify.go | 17 ++-- .../core/frontend/chunkstore/layout_verify.go | 18 +++- .../core/frontend/chunkstore/swfs_head.go | 85 +++++++++++++++++++ .../frontend/chunkstore/swfs_head_test.go | 80 +++++++++++++++++ .../chunkstore/verify_bindings_stat_test.go | 85 ++++++++++++++++++- .../verify_production_layout_test.go | 4 + seaweed-block/docs/design/invariants.md | 3 +- seaweed-block/docs/standalone-deployment.md | 9 +- 10 files changed, 300 insertions(+), 13 deletions(-) create mode 100644 seaweed-block/core/frontend/chunkstore/swfs_head.go create mode 100644 seaweed-block/core/frontend/chunkstore/swfs_head_test.go diff --git a/seaweed-block/cmd/sw-block/chunk_verify.go b/seaweed-block/cmd/sw-block/chunk_verify.go index f8dbbac4e2..71cf5b19e9 100644 --- a/seaweed-block/cmd/sw-block/chunk_verify.go +++ b/seaweed-block/cmd/sw-block/chunk_verify.go @@ -37,7 +37,7 @@ func chunkVerify(args []string, stdout, stderr io.Writer) int { fs.StringVar(&base, "chunk-path", defaultChunkPathCLI, "filer directory holding one directory per volume") fs.StringVar(&snapshot, "snapshot", "", "unsupported: every snapshot HEAD names is always checked") fs.BoolVar(&allSnapshots, "all-snapshots", false, "unsupported: every snapshot HEAD names is always checked") - fs.StringVar(&depth, "depth", "bindings", "meta or bindings: named filer entries and declared sizes; data: and every chunk's bytes hash to its name") + fs.StringVar(&depth, "depth", "bindings", "meta or bindings: named filer entries, sizes and needle HEAD; data: and every chunk's bytes hash to its name") fs.BoolVar(&orphans, "orphans", false, "also report the volume's own names no reachable root names (report only)") fs.IntVar(&concurrency, "concurrency", 1, "unsupported: chunks are read one at a time") fs.Int64Var(&bytesPerSec, "bytes-per-sec", 0, "unsupported: chunk reads are not paced") diff --git a/seaweed-block/core/frontend/chunkstore/fake_test.go b/seaweed-block/core/frontend/chunkstore/fake_test.go index 273ae134c2..b1bc06d73f 100644 --- a/seaweed-block/core/frontend/chunkstore/fake_test.go +++ b/seaweed-block/core/frontend/chunkstore/fake_test.go @@ -264,6 +264,16 @@ type fakeBlobs struct { func newFakeBlobs() *fakeBlobs { return &fakeBlobs{data: map[string][]byte{}} } +func (b *fakeBlobs) HeadBlob(_ context.Context, fid string) (uint64, error) { + b.mu.Lock() + defer b.mu.Unlock() + d, ok := b.data[fid] + if !ok { + return 0, ErrBlobNotFound + } + return uint64(len(d)), nil +} + func (b *fakeBlobs) Put(_ context.Context, d []byte) (string, error) { b.mu.Lock() defer b.mu.Unlock() diff --git a/seaweed-block/core/frontend/chunkstore/layout/verify.go b/seaweed-block/core/frontend/chunkstore/layout/verify.go index 7433730f67..85ee3422e9 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/verify.go +++ b/seaweed-block/core/frontend/chunkstore/layout/verify.go @@ -69,8 +69,8 @@ type verifier struct { res VerifyResult 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 - checked map[string]bool // chunk paths checked across all roots + owners map[string]ownerID // VOLUME id per chunk owner, read once + checked map[verifyChunkKey]bool // exact immutable chunk identities across all roots geometry map[string]Geometry ownID VolumeID } @@ -80,6 +80,12 @@ type ownerID struct { ok bool } +type verifyChunkKey struct { + owner VolumeID + index uint64 + hash Hash +} + // 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) { @@ -98,7 +104,7 @@ func Verify(ctx context.Context, base, vol string, fetch Fetch, opts VerifyOptio if opts.Orphans && opts.List == nil { return VerifyResult{}, errors.New("layout: verify orphans needs a list") } - v := &verifier{base: base, vol: vol, fetch: fetch, opts: opts, ownPool: map[string]bool{}, ownMeta: map[string]bool{}, owners: map[string]ownerID{}, checked: map[string]bool{}, geometry: map[string]Geometry{}} + v := &verifier{base: base, vol: vol, fetch: fetch, opts: opts, ownPool: map[string]bool{}, ownMeta: map[string]bool{}, owners: map[string]ownerID{}, checked: map[verifyChunkKey]bool{}, geometry: map[string]Geometry{}} v.res.Complete = true head, ok, err := v.head(ctx, vol) if err != nil { @@ -327,10 +333,11 @@ func (v *verifier) chunks(ctx context.Context, r *Reader, seg Segment, count boo 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.checked[p] { + key := verifyChunkKey{owner: ref.OwnerID, index: ref.Chunk.Index, hash: ref.Chunk.Hash} + if v.checked[key] { continue } - v.checked[p] = true + v.checked[key] = true if v.opts.Depth == DepthFull { if _, err := r.get(ctx, dir, ref.Chunk.Path(), ref.Chunk.Hash); err != nil { if err := v.classify(p, err); err != nil { diff --git a/seaweed-block/core/frontend/chunkstore/layout_verify.go b/seaweed-block/core/frontend/chunkstore/layout_verify.go index 7977d946e2..813d8ca138 100644 --- a/seaweed-block/core/frontend/chunkstore/layout_verify.go +++ b/seaweed-block/core/frontend/chunkstore/layout_verify.go @@ -120,8 +120,8 @@ func VerifyLayout(ctx context.Context, f Filer, base, vol string, opts layout.Ve return res, nil } -// verifyStat checks the filer's binding and size, not the needle's bytes. -// Reading and hashing those bytes belongs to data depth. +// verifyStat checks the filer binding and the needle's existence and size by +// HEAD. Reading and hashing the response body belongs to data depth. func (s *LayoutStore) verifyStat(ctx context.Context, p string, expectedSize uint64) (bool, error) { if !path.IsAbs(p) || path.Clean(p) != p || !strings.HasPrefix(p, path.Dir(s.root)+"/") { return false, errors.New("chunkstore: object path outside the store base") @@ -148,6 +148,20 @@ func (s *LayoutStore) verifyStat(ctx context.Context, p string, expectedSize uin if len(e.Content) != 0 || len(e.Chunks) != 1 || e.Chunks[0] == nil || e.Chunks[0].Offset != 0 || e.Chunks[0].FileId == "" || e.Attributes == nil || e.Attributes.FileSize != e.Chunks[0].Size || e.Attributes.FileSize != expectedSize { return false, fmt.Errorf("%w: invalid file binding or size for %s", layout.ErrCorrupt, p) } + head, ok := s.b.(BlobHeaders) + if !ok { + return false, errors.New("chunkstore: verify needs needle HEAD support") + } + size, err := head.HeadBlob(ctx, e.Chunks[0].FileId) + if errors.Is(err, ErrBlobNotFound) { + return false, nil + } + if err != nil { + return false, err + } + if size != expectedSize { + return false, fmt.Errorf("%w: needle size differs from VOLUME geometry for %s", layout.ErrCorrupt, p) + } return true, nil } diff --git a/seaweed-block/core/frontend/chunkstore/swfs_head.go b/seaweed-block/core/frontend/chunkstore/swfs_head.go new file mode 100644 index 0000000000..9b9efeb100 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/swfs_head.go @@ -0,0 +1,85 @@ +package chunkstore + +import ( + "context" + "errors" + "fmt" + "net/http" + "strings" +) + +// BlobHeaders checks needle existence and logical size without transferring its +// body to the client. The volume server may read small needles internally. +type BlobHeaders interface { + HeadBlob(context.Context, string) (uint64, error) +} + +// HeadBlob resolves every replica with the same fresh-location absence rule as +// Get. A reachable copy is sufficient; only all fresh 404s prove absence. +func (c *SWFS) HeadBlob(ctx context.Context, fid string) (uint64, error) { + vid, needle, ok := strings.Cut(fid, ",") + if !ok || vid == "" || needle == "" || strings.ContainsAny(fid, "/\\?#% \r\n") { + return 0, fmt.Errorf("chunkstore: bad fid %q", fid) + } + urls, cached, err := c.lookupVolume(ctx, vid) + if err != nil { + return 0, err + } + for attempt := 0; ; attempt++ { + size, absent, readErr := c.headFromAll(ctx, urls, fid) + if readErr == nil { + return size, nil + } + c.mu.Lock() + delete(c.vidCache, vid) + c.mu.Unlock() + if absent && cached && attempt == 0 { + urls, _, err = c.lookupVolume(ctx, vid) + if err != nil { + return 0, err + } + continue + } + if absent { + readErr = &blobNotFoundError{readErr} + } + return 0, fmt.Errorf("chunkstore: HEAD %s: %w", fid, readErr) + } +} + +func (c *SWFS) headFromAll(ctx context.Context, urls []string, fid string) (uint64, bool, error) { + absent := true + var last error + for _, host := range urls { + req, err := http.NewRequestWithContext(ctx, http.MethodHead, "http://"+host+"/"+fid, nil) + if err != nil { + return 0, false, err + } + resp, err := c.http.Do(req) + if err == nil { + closeErr := resp.Body.Close() + switch { + case closeErr != nil: + err = closeErr + case resp.StatusCode != http.StatusOK: + err = &blobStatusError{code: resp.StatusCode, host: host} + case resp.ContentLength < 0: + err = errors.New("chunkstore: needle HEAD has no size") + default: + return uint64(resp.ContentLength), false, nil + } + } + last = err + var se *blobStatusError + if !errors.As(err, &se) || se.code != http.StatusNotFound { + absent = false + } + } + if last == nil { + last = errors.New("chunkstore: needle HEAD has no locations") + absent = false + } + return 0, absent, last +} + +var _ BlobHeaders = (*SWFS)(nil) diff --git a/seaweed-block/core/frontend/chunkstore/swfs_head_test.go b/seaweed-block/core/frontend/chunkstore/swfs_head_test.go new file mode 100644 index 0000000000..8cb6af0068 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/swfs_head_test.go @@ -0,0 +1,80 @@ +package chunkstore + +import ( + "context" + "errors" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" +) + +func TestSWFSHeadBlobUsesOnlyHEADAndClassifiesAbsence(t *testing.T) { + for _, tc := range []struct { + name, length string + status int + missing bool + wantError bool + }{ + {"exists", "4194304", 200, false, false}, + {"missing", "0", 404, true, true}, + {"unavailable", "0", 503, false, true}, + {"size-unavailable", "", 200, false, true}, + } { + t.Run(tc.name, func(t *testing.T) { + methods := make(chan string, 4) + vol := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + methods <- r.Method + if tc.length != "" { + w.Header().Set("Content-Length", tc.length) + } + w.WriteHeader(tc.status) + })) + defer vol.Close() + host := strings.TrimPrefix(vol.URL, "http://") + f := &fakeFilerGRPC{lookupVol: &filerpb.LookupVolumeResponse{LocationsMap: map[string]*filerpb.Locations{"7": {Locations: []*filerpb.Location{{Url: host}}}}}} + c := startFakeFiler(t, f) + size, err := c.HeadBlob(context.Background(), "7,01abcdef") + if (err != nil) != tc.wantError || errors.Is(err, ErrBlobNotFound) != tc.missing || !tc.wantError && size != 4194304 { + t.Fatalf("size=%d err=%v", size, err) + } + if method := <-methods; method != http.MethodHead { + t.Fatalf("body request %s", method) + } + }) + } +} + +func TestSWFSHeadBlobRefreshesCachedMissingLocation(t *testing.T) { + stale := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(404) })) + defer stale.Close() + live := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodHead { + t.Errorf("body request %s", r.Method) + } + w.Header().Set("Content-Length", "4096") + })) + defer live.Close() + f := &fakeFilerGRPC{lookupVol: &filerpb.LookupVolumeResponse{LocationsMap: map[string]*filerpb.Locations{"7": {Locations: []*filerpb.Location{{Url: strings.TrimPrefix(live.URL, "http://")}}}}}} + c := startFakeFiler(t, f) + c.vidCache["7"] = []string{strings.TrimPrefix(stale.URL, "http://")} + size, err := c.HeadBlob(context.Background(), "7,01abcdef") + if err != nil || size != 4096 || f.volLookups != 1 { + t.Fatalf("size=%d err=%v fresh lookups=%d", size, err, f.volLookups) + } +} + +func TestSWFSHeadBlobMixedReplicaFailureDoesNotProveAbsence(t *testing.T) { + missing := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(404) })) + defer missing.Close() + failed := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(503) })) + defer failed.Close() + f := &fakeFilerGRPC{lookupVol: &filerpb.LookupVolumeResponse{LocationsMap: map[string]*filerpb.Locations{"7": {Locations: []*filerpb.Location{{Url: strings.TrimPrefix(failed.URL, "http://")}, {Url: strings.TrimPrefix(missing.URL, "http://")}}}}}} + c := startFakeFiler(t, f) + _, err := c.HeadBlob(context.Background(), "7,01abcdef") + if err == nil || errors.Is(err, ErrBlobNotFound) { + t.Fatalf("mixed operational/404 answer: %v", err) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go b/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go index 37da50da03..09440743ac 100644 --- a/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go +++ b/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go @@ -55,6 +55,84 @@ func TestVerifyBindingsNeverReadsChunkBodies(t *testing.T) { } } +func TestVerifyBindingsReportsMissingNeedleBehindPresentEntry(t *testing.T) { + fb, id := verifyBlobFixture(t) + dir := layout.VolumeDir("v", id) + n := layout.NameChunk(0, []byte(strings.Repeat("a", 4*4096))) + e := fb.fakeFiler.entries[path.Join("/blocks", dir, n.Path())] + delete(fb.fakeBlobs.data, e.Chunks[0].FileId) + _, before, _ := fb.fakeBlobs.counts() + res, err := VerifyLayout(context.Background(), fb, "/blocks", dir, layout.VerifyOptions{Depth: layout.DepthNames}) + _, after, _ := fb.fakeBlobs.counts() + if err != nil || !res.Complete || len(res.Findings) != 1 || res.Findings[0].Class != layout.FindMissing || after != before { + t.Fatalf("missing needle without body reads: %+v, %v, gets=%d", res, err, after-before) + } +} + +type verifyNeedleFailure struct { + filerBlobs + err error + size uint64 +} + +func (f verifyNeedleFailure) HeadBlob(context.Context, string) (uint64, error) { + return f.size, f.err +} + +func TestVerifyBindingsNeedleFailureAndSize(t *testing.T) { + fb, id := verifyBlobFixture(t) + injected := errors.New("needle service unavailable") + res, err := VerifyLayout(context.Background(), verifyNeedleFailure{filerBlobs: fb, err: injected}, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: layout.DepthNames}) + if !errors.Is(err, injected) || res.Complete || len(res.Findings) != 0 { + t.Fatalf("unavailable needle: %+v, %v", res, err) + } + res, err = VerifyLayout(context.Background(), verifyNeedleFailure{filerBlobs: fb, size: 32}, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: layout.DepthNames}) + if err != nil || !res.Complete || len(res.Findings) != 2 { + t.Fatalf("wrong needle sizes: %+v, %v", res, err) + } + for _, f := range res.Findings { + if f.Class != layout.FindCorrupt { + t.Fatalf("wrong-size class: %+v", f) + } + } +} + +func TestVerifyDistinctChunksRetainHashAcrossSnapshots(t *testing.T) { + for _, depth := range []string{layout.DepthNames, layout.DepthFull} { + t.Run(depth, func(t *testing.T) { + fb, id := verifyBlobFixture(t) + dir := path.Join("/blocks", layout.VolumeDir("v", id)) + missing := layout.NameChunk(0, []byte(strings.Repeat("z", 4*4096))) + root, segs, err := layout.Build(map[uint64]layout.Ref{0: {Owner: "v", OwnerID: id, Chunk: missing}}) + if err != nil { + t.Fatal(err) + } + for n, b := range segs { + putFile(t, fb.fakeFiler, path.Join(dir, n.Path()), b) + } + rn, raw, err := layout.NameRoot(root) + if err != nil { + t.Fatal(err) + } + putFile(t, fb.fakeFiler, path.Join(dir, rn.Path()), raw) + e := fb.fakeFiler.entries[path.Join(dir, layout.HeadName)] + h, err := layout.DecodeHead(e.Content, 0, id) + if err != nil { + t.Fatal(err) + } + h.Snapshots = map[string]layout.Snapshot{"older": {Root: rn}} + e.Content, err = h.Encode() + if err != nil { + t.Fatal(err) + } + res, err := VerifyLayout(context.Background(), fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: depth}) + if err != nil || !res.Complete || len(res.Findings) != 1 || res.Findings[0].Class != layout.FindMissing || res.Findings[0].Path != path.Join(layout.VolumeDir("v", id), missing.Path()) { + t.Fatalf("different content at the same owner/index: %+v, %v", res, err) + } + }) + } +} + type verifyLookupCounter struct { filerBlobs reads map[string]int @@ -205,6 +283,10 @@ type verifyPayloadCounter struct { payloadReads, metadataReads int } +func (f *verifyPayloadCounter) HeadBlob(ctx context.Context, fid string) (uint64, error) { + return f.Blobs.(BlobHeaders).HeadBlob(ctx, fid) +} + func (f *verifyPayloadCounter) Get(ctx context.Context, fid string) ([]byte, error) { if f.payloads[fid] { f.payloadReads++ @@ -279,8 +361,9 @@ func TestVerifyBindingsUsesTailGeometryAndRejectsOutsideVolume(t *testing.T) { t.Fatal(err) } p := path.Join(dir, layout.NameChunk(5, []byte(strings.Repeat("f", 4*4096))).Path()) - // Names depth observes declared metadata only; it must not read this body. + // A valid tail has both a shortened needle and matching metadata. e := fb.fakeFiler.entries[p] + fb.fakeBlobs.data[e.Chunks[0].FileId] = fb.fakeBlobs.data[e.Chunks[0].FileId][:4096] e.Attributes.FileSize, e.Chunks[0].Size = 4096, 4096 if mode == "short-tail" { e.Attributes.FileSize, e.Chunks[0].Size = 2048, 2048 diff --git a/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go b/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go index cd435c590d..416de9c193 100644 --- a/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go +++ b/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go @@ -16,6 +16,10 @@ type verifyProductionStore struct { Blobs } +func (f verifyProductionStore) HeadBlob(ctx context.Context, fid string) (uint64, error) { + return f.Blobs.(BlobHeaders).HeadBlob(ctx, fid) +} + // 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) { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index f76ca2fcd9..d513ea9684 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -1060,7 +1060,8 @@ Notes: | `INV-SNAP-SCHEDULE-RESTART-001` | A new snapshot worker seeds its last success from HEAD's newest scheduled creation time (future clamped to now), then the next stable per-volume grid slot; absent history is due now. Restarts preserve overdue age; manual snapshots do not seed it. | M8 scheduled worker Armed → Due | `core/frontend/durable/chunk_snapshot_schedule.go` `snapshotScheduleFromHead`; `provider_chunk.go` `newChunkLayer` | `TestScheduledSnapshotRestartsStillTakeTheDueSnapshot`, `TestScheduledSnapshotRestartPreservesOverdueFromHEAD`, `TestScheduledSnapshotWithoutHistoryIsImmediatelyDue`, `TestScheduledSnapshotProvidersSpreadAfterImmediateFirstAttempt`, `TestSnapshotScheduleHeadSeedKeepsPerVolumeGrid`, `TestSnapshotScheduleHeadSeedClampsFutureCreationTime` | — (read-only timer initialization from existing HEAD metadata) | ACTIVE | | `INV-SNAP-SCHEDULED-KEEP-001` | Retention keeps the newest K scheduled snapshots, K being the newest one's swb.schedule.keep (default 7); scheduled snapshots never count against KeepNewest or get age keeps, so other snapshots are planned as if they were absent. | M6 snapshot: Published → Deleting (retention, class `scheduled`) | `core/frontend/chunkstore/retain/retain.go` `Plan`, `scheduleKeepOf` | `TestPlanRetention_ScheduledClassKeepsItsOwnNewest`, `TestPlanRetention_PinnedScheduledStaysInItsClass` (`core/frontend/chunkstore/retain/retain_test.go`) | — | ACTIVE | | `INV-VERIFY-READONLY-001` | Verify writes nothing at any depth: it reaches the store only through Fetch, Stat and List, and a full pass with orphans leaves every filer entry and blob unchanged. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyLayoutThroughTheAdapter` (`core/frontend/chunkstore/layout_verify_test.go`) | — | ACTIVE | -| `INV-VERIFY-BINDINGS-001` | Bindings depth checks each chunk's filer binding and size against its owner's VOLUME geometry (tail excepted), without reading the blob body. | M6 reader (no transition) | `core/frontend/chunkstore/layout_verify.go` `verifyStat`; `core/frontend/chunkstore/layout/verify.go` `chunks` | `TestVerifyBindingsNeverReadsChunkBodies`, `TestVerifyBindingsChecksDeclaredSizesAndRefusals`, `TestVerifyBindingsLookupFailureIsNotAMissingObject`, `TestVerifyBindingsRejectsSelfConsistentTruncationAgainstGeometry`, `TestVerifyBindingsUsesTailGeometryAndRejectsOutsideVolume` | — (read-only inspection) | ACTIVE | +| `INV-VERIFY-BINDINGS-001` | Bindings checks each chunk's filer binding, declared size and needle HEAD size against its owner's VOLUME geometry (tail excepted), without transferring the blob body. | M6 reader (no transition) | `core/frontend/chunkstore/layout_verify.go` `verifyStat`; `core/frontend/chunkstore/layout/verify.go` `chunks` | `TestVerifyBindingsNeverReadsChunkBodies`, `TestVerifyBindingsChecksDeclaredSizesAndRefusals`, `TestVerifyBindingsLookupFailureIsNotAMissingObject`, `TestVerifyBindingsRejectsSelfConsistentTruncationAgainstGeometry`, `TestVerifyBindingsUsesTailGeometryAndRejectsOutsideVolume` | — (read-only inspection) | ACTIVE | +| `INV-VERIFY-NEEDLE-001` | Bindings reports a missing needle only after every freshly resolved location answers 404; operational failures remain incomplete. A needle HEAD never falls back to a client GET. | M6 reader (no transition) | `core/frontend/chunkstore/swfs_head.go` `HeadBlob`; `core/frontend/chunkstore/layout_verify.go` `verifyStat` | `TestVerifyBindingsReportsMissingNeedleBehindPresentEntry`, `TestSWFSHeadBlobUsesOnlyHEADAndClassifiesAbsence`, `TestSWFSHeadBlobRefreshesCachedMissingLocation` | — (read-only inspection) | ACTIVE | | `INV-VERIFY-DISTINCT-001` | A verify pass looks up each immutable metadata object and chunk binding once across roots; HEAD remains independently confirmed, and chunk bodies are never retained in the metadata cache. | M6 reader (no transition) | `core/frontend/chunkstore/layout_verify.go` `VerifyLayout`; `core/frontend/chunkstore/layout/verify.go` `chunks` | `TestVerifyBindingsChecksEachDistinctObjectOnce` | — (pass-local reuse) | ACTIVE | | `INV-VERIFY-STABLE-HEAD-001` | Filer verify publishes MISSING or ORPHAN only after two HEAD observations agree on a nonzero generation and volume identity. An unavailable or changed own/dependent HEAD makes the pass incomplete and suppresses those findings. Unsupported verify options refuse before dialing. | M6 (reader; no transition) | `core/frontend/chunkstore/layout_verify.go` `VerifyLayout`; `cmd/sw-block/chunk_verify.go` `chunkVerify` | `TestVerifyLayoutRequiresStableHeadForMissingAndOrphans`; `TestVerifyConfirmsDependentHeadBeforeReportingOrphans`; `TestOpsChunkVerifyRefusesUnsupportedFlagsBeforeDial` | — | ACTIVE | | `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 | diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index e489e42760..15ad5eba72 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -871,9 +871,12 @@ directories using each reference's full owner id. The default `--depth bindings` (also named `meta`) checks each distinct chunk's filer entry and its declared size against its owner's VOLUME geometry (including -the final partial chunk) without fetching the chunk -body. It does not detect content damage or a missing backing needle behind a -present entry; use `--depth data` for those checks. Roots and segments are still +the final partial chunk), then checks the backing needle's existence and size +using HTTP HEAD without downloading its body. A missing needle behind a present +entry is MISSING; an unreachable server makes the pass incomplete. This does +not detect same-size content damage; use `--depth data` for the hash check. +SeaweedFS 4.53 reads only metadata for ordinary uncompressed 4 MiB needles on +HEAD, but may read small needles internally. Roots and segments are still read and decoded, and shared immutable objects are checked once per pass. Verify is read-only: exit 0 means complete with no findings, 3 means complete