diff --git a/seaweed-block/core/frontend/durable/default_attach_attempt_test.go b/seaweed-block/core/frontend/durable/default_attach_attempt_test.go index 86b69a3445..95ac090234 100644 --- a/seaweed-block/core/frontend/durable/default_attach_attempt_test.go +++ b/seaweed-block/core/frontend/durable/default_attach_attempt_test.go @@ -131,3 +131,39 @@ func TestDefaultAttachAt262144EntriesOutlivesAssignmentWait(t *testing.T) { } t.Logf("default attach served after %s, allowance=%s segments=%d entries=%d progress=%d", time.Since(start), allowance, f.fetched.Load(), entries, completed.Load()) } + +// Removing the whole-attempt timer must not turn a broken store into an +// endless startup retry, nor let the assignment wait serve without a grant. +func TestDefaultGrantedAttachFailureEndsAtAssignmentAllowance(t *testing.T) { + v := &arrivingAssignment{seen: make(chan struct{}), assigned: make(chan struct{})} + cfg := durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkAssignmentTimeout: time.Millisecond} + testutil.NewLayoutFixture(t, "v1", 64, 4).Configure(&cfg) + cfg.ChunkLayoutHeadFor = func(string) (layout.StartStore, error) { return nil, errHeadRead } + p, err := durable.NewDurableProvider(cfg, v) + if err != nil { + t.Fatal(err) + } + defer p.Close() + if _, err := p.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + v.active.Store(true) + if _, err := p.RecoverVolume(context.Background(), "v1"); err != nil { + t.Fatal(err) + } + close(v.assigned) + deadline := time.Now().Add(2 * time.Second) + for { + if _, failed := p.ChunkStartupOutcome("v1"); failed { + break + } + if time.Now().After(deadline) { + t.Fatal("failed default attach retried past its assignment allowance") + } + time.Sleep(time.Millisecond) + } + statuses := p.DurableStatuses() + if len(statuses) != 1 || statuses[0].Operational || !strings.Contains(statuses[0].Evidence, "deadline exceeded") { + t.Fatal("expired attach did not stay non-serving with the deadline outcome") + } +}