From 7d40a0e2058f84f31128bc1fd6e9abeb4748cf6a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 15 Nov 2026 14:17:41 -0800 Subject: [PATCH] fix(gc): accept SeaweedFS completed-delete status and verify raw needle absence --- seaweed-block/cmd/sw-block/chunk_gc_integration_test.go | 6 ++++++ seaweed-block/cmd/sw-block/main.go | 1 + seaweed-block/core/frontend/chunkstore/GC.md | 2 +- seaweed-block/core/frontend/chunkstore/swfs.go | 3 ++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/seaweed-block/cmd/sw-block/chunk_gc_integration_test.go b/seaweed-block/cmd/sw-block/chunk_gc_integration_test.go index f168212e56..7038c49a9d 100644 --- a/seaweed-block/cmd/sw-block/chunk_gc_integration_test.go +++ b/seaweed-block/cmd/sw-block/chunk_gc_integration_test.go @@ -169,10 +169,16 @@ func TestIntegration_OpsChunkGC_RealMasterAndStore(t *testing.T) { if got, err := remote.Get(ctx, "orphan"); err != nil || !bytes.Equal(got, data) { t.Fatalf("preview deleted blob: %q %v", got, err) } + if got, err := s.Get(ctx, preview.WouldDelete[0].FID); err != nil || !bytes.Equal(got, data) { + t.Fatalf("raw orphan before delete: %q %v", got, err) + } applied := call(true) if applied.Reclaimed != 1 || applied.ExpiredIntents != 0 || !applied.MarkSaved { t.Fatalf("apply: %+v", applied) } + if _, err := s.Get(ctx, preview.WouldDelete[0].FID); err == nil { + t.Fatal("raw orphan needle still readable after DELETE") + } if _, err = remote.Get(ctx, "orphan"); err == nil { t.Fatal("orphan still readable") } diff --git a/seaweed-block/cmd/sw-block/main.go b/seaweed-block/cmd/sw-block/main.go index 1d0c628ad6..2c2bd65dea 100644 --- a/seaweed-block/cmd/sw-block/main.go +++ b/seaweed-block/cmd/sw-block/main.go @@ -2292,6 +2292,7 @@ func usage(w io.Writer) { fmt.Fprintln(w, " sw-block ops chunk snapshots|snapshot-delete --volume [--name ] --chunk-filer [--chunk-path /swblock/chunks]") fmt.Fprintln(w, " sw-block ops chunk fork --chunk-filer [--chunk-path /swblock/chunks] --source --snapshot --target [--request-id ] [--label k=v]...") fmt.Fprintln(w, " sw-block ops chunk show --volume --chunk-filer [--chunk-path /swblock/chunks]") + fmt.Fprintln(w, " sw-block ops chunk gc --chunk-filer --master [--chunk-path /swblock/chunks] [--apply] [--grace 1h] [--intent-ttl 1h] [--timeout 1m]") } func emptyCLI(value string) string { diff --git a/seaweed-block/core/frontend/chunkstore/GC.md b/seaweed-block/core/frontend/chunkstore/GC.md index f650b4f7d7..512af5f402 100644 --- a/seaweed-block/core/frontend/chunkstore/GC.md +++ b/seaweed-block/core/frontend/chunkstore/GC.md @@ -6,7 +6,7 @@ A capture intent can expire only when its age strictly exceeds IntentTTL, the bl An immutable binding becomes a candidate only when its creation time is strictly older than Grace and no root names it. Reclamation requires another successful mark at least Grace after its first observation with the same binding bytes. A rooted candidate is forgotten; failed marks discard coverage. A bare Collector restart discards coverage; ExecuteGC restores only a completed, configuration-matching filer mark. Grace must exceed the catalog operation deadline plus the measured mark duration. Backward clock movement refuses the pass. -Before physical deletion the binding receives a conditional `swb.gc.deleted=1` tombstone; after every resolved replica deletion succeeds it becomes `done`. Bindings are never removed or rebound. Failed/uncertain blob deletion returns an error and retains the fid for a conservative retry after fresh marks. The SeaweedFS adapter deletes the exact fid, accepts only HTTP 200/204/404, and propagates transport/other HTTP failures. Authenticated deployments must supply a BlobDeleter with their write authorization; this patch does not add an auth provisioning path. +Before physical deletion the binding receives a conditional `swb.gc.deleted=1` tombstone; after every resolved replica deletion succeeds it becomes `done`. Bindings are never removed or rebound. Failed/uncertain blob deletion returns an error and retains the fid for a conservative retry after fresh marks. The SeaweedFS adapter deletes the exact fid, accepts only HTTP 200/202/204/404 (SeaweedFS returns 202 after synchronous replicated deletion), and propagates transport/other HTTP failures. Authenticated deployments must supply a BlobDeleter with their write authorization; this patch does not add an auth provisioning path. Unbound needles (upload succeeded but key binding never persisted) are RETAINED. The existing interfaces cannot enumerate/count them, so `UnknownUnbound=true` reports that limitation instead of a fabricated zero. No sweep is attempted. diff --git a/seaweed-block/core/frontend/chunkstore/swfs.go b/seaweed-block/core/frontend/chunkstore/swfs.go index c3c375df50..1180b84e87 100644 --- a/seaweed-block/core/frontend/chunkstore/swfs.go +++ b/seaweed-block/core/frontend/chunkstore/swfs.go @@ -323,6 +323,7 @@ var ( // DeleteBlob removes an immutable needle from every resolved replica. A // partial/unknown result is an error, so GC retains its binding tombstone // and retries later; no response body is used to infer success. +// SeaweedFS writeDeleteResult returns 202 after ReplicatedDelete completes. func (c *SWFS) DeleteBlob(ctx context.Context, fid string) error { vid, needle, ok := strings.Cut(fid, ",") if !ok || vid == "" || needle == "" || strings.ContainsAny(fid, "/\\?#% \r\n") { @@ -342,7 +343,7 @@ func (c *SWFS) DeleteBlob(ctx context.Context, fid string) error { return err } resp.Body.Close() - if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusNotFound { + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted && resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusNotFound { return fmt.Errorf("chunkstore: delete %s: http %d", fid, resp.StatusCode) } }