From f829e8751e538fa0e392c96b4dc08ea40610aea5 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 29 Nov 2026 14:50:55 -0800 Subject: [PATCH] durable: a plain seal's retry after a deadline commits the first attempt's uploads without putting them again Co-Authored-By: Claude Opus 5.5 --- .../durable/provider_seal_progress_test.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider_seal_progress_test.go b/seaweed-block/core/frontend/durable/provider_seal_progress_test.go index 15c28f723b..a4fd6b58df 100644 --- a/seaweed-block/core/frontend/durable/provider_seal_progress_test.go +++ b/seaweed-block/core/frontend/durable/provider_seal_progress_test.go @@ -122,26 +122,24 @@ func TestPlainSealDeadlineRetryUploadsOnlyRemainingChunks(t *testing.T) { t.Fatalf("first attempt progress: calls=%d successful=%d bytes=%d", remote.calls, len(remote.keys), remote.bytes) } firstKeys := append([]string(nil), remote.keys...) - if _, _, err := p.DetachVolumePlain(parent, "v1"); !errors.Is(err, durable.ErrDetachAborted) || !errors.Is(err, storage.ErrChunkHeadPrecondition) { - t.Fatalf("staged chunks from the ended session were accepted: %v", err) - } + // The retry runs in a new session and commits what the first attempt + // uploaded in its ended one: the commit adopts those objects, so only + // the remaining chunks are put, and the seal completes in one retry. r, last, err := p.DetachVolumePlain(parent, "v1") if err != nil || r.Head.State != storage.ChunkHeadDetached || r.H != last || r.Head.RemoteLSN != last { t.Fatalf("plain seal retry failed: %+v last=%d err=%v", r, last, err) } - if len(remote.keys) != 2*chunks || remote.bytes != 2*chunks*chunkBytes { - t.Fatalf("the refused cut did not restage in its new session: successful=%d bytes=%d", len(remote.keys), remote.bytes) + if len(remote.keys) != chunks || remote.bytes != chunks*chunkBytes { + t.Fatalf("the retry put %d chunks in all (%d bytes); want %d: the first attempt's 2 adopted, only the rest put", len(remote.keys), remote.bytes, chunks) } if len(remote.images) != chunks { - t.Fatalf("restaged image has %d distinct payloads, want %d", len(remote.images), chunks) + t.Fatalf("sealed image has %d distinct payloads, want %d", len(remote.images), chunks) } for _, n := range remote.images { - if n != 2 { - t.Fatalf("unexpected session PUT count %d", n) + if n != 1 { + t.Fatalf("a chunk was put %d times; want once", n) } } - // The kernel requires a Put in the new session, but the content-named - // filer entry is reused by a conditional metadata update, not a blob PUT. c.blobs.Lock() physical := map[[32]byte]int{} for _, raw := range c.blobs.blobs {