mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
fix(gc): accept SeaweedFS completed-delete status and verify raw needle absence
This commit is contained in:
1 parent
1fc3d1f45b
commit
7d40a0e205
4 files changed
+10
-2
No files matched your search
@@ -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")
|
||||
}
|
||||
|
||||
@@ -2292,6 +2292,7 @@ func usage(w io.Writer) {
|
||||
fmt.Fprintln(w, " sw-block ops chunk snapshots|snapshot-delete --volume <id> [--name <name>] --chunk-filer <host:port> [--chunk-path /swblock/chunks]")
|
||||
fmt.Fprintln(w, " sw-block ops chunk fork --chunk-filer <host:port> [--chunk-path /swblock/chunks] --source <id> --snapshot <name> --target <id> [--request-id <id>] [--label k=v]...")
|
||||
fmt.Fprintln(w, " sw-block ops chunk show --volume <id> --chunk-filer <host:port> [--chunk-path /swblock/chunks]")
|
||||
fmt.Fprintln(w, " sw-block ops chunk gc --chunk-filer <host:port> --master <blockmaster-grpc> [--chunk-path /swblock/chunks] [--apply] [--grace 1h] [--intent-ttl 1h] [--timeout 1m]")
|
||||
}
|
||||
|
||||
func emptyCLI(value string) string {
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user