From 62813dc9a87dcc206f4a79bbfb34a0912c2ee9b6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 22:23:37 -0800 Subject: [PATCH] test(storage): exercise upload retries beyond the WAL with periodic flushes --- .../core/storage/chunk_upload_retry_test.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/seaweed-block/core/storage/chunk_upload_retry_test.go b/seaweed-block/core/storage/chunk_upload_retry_test.go index cbee7db935..a03441690c 100644 --- a/seaweed-block/core/storage/chunk_upload_retry_test.go +++ b/seaweed-block/core/storage/chunk_upload_retry_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "path/filepath" "sync" "testing" "time" @@ -115,3 +116,33 @@ func TestChunkCutUploadRetryHonorsDeadlineAndRetainsDirt(t *testing.T) { } assertEveryHeadIsPrefixImage(t, f, w) } + +func TestChunkCutRetrySustainedWritesPastWALWithFlush(t *testing.T) { + const walBytes = 64 * 1024 + s, err := createMappedWALStoreV3ForTest(filepath.Join(t.TempDir(), "volume"), ctNumBlocks, ctBlockSize, walBytes, WModeStrict, ctChunkBlocks) + if err != nil { + t.Fatal(err) + } + s.DisableAutoFlushForRecoveryTest() + t.Cleanup(func() { closeBounded(t, s) }) + f := newFakeChunkRemote() + r := &retryUploadRemote{fakeChunkRemote: f, mode: "transient", calls: map[string]int{}} + layer := mustAttach(t, s, r, ctConfig(1)) + w := newWriteLog() + for i := 0; i < 96; i++ { + w.write(t, s, uint32(i%ctNumBlocks), byte(i+1)) + if (i+1)%4 == 0 { + mustSyncFlush(t, s) + } + if (i+1)%16 == 0 { + if _, err := layer.Cut(ctTimeout(t)); err != nil { + t.Fatal(err) + } + } + } + assertEveryHeadIsPrefixImage(t, f, w) + if len(f.installedHeads()) != 6 { + t.Fatalf("published %d HEADs", len(f.installedHeads())) + } + t.Logf("payload=%d > WAL=%d; 24 periodic flushes; 6 cuts with transient upload faults", 96*ctBlockSize, walBytes) +}