Expose volume-sized local recovery inside the startup deadline

This commit is contained in:
pingqiu committed 2026-11-29 00:39:49 -08:00
1 parent c6e3589dec
commit 6b49a1711a
1 file changed
+47
@@ -0,0 +1,47 @@
package main
import (
"context"
"testing"
"time"
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
"github.com/seaweedfs/seaweed-block/core/storage"
)
// This counting provider represents local map replay without disk throughput or
// wall-clock sleeps. It probes the production startup boundary, not a widened
// deadline: a per-volume walk must not inherit the attach operation's timer.
type countingLocalRecovery struct {
entries int
visited int
underDeadline int
}
func (p *countingLocalRecovery) EnsureStorage(string) (storage.LogicalStorage, error) {
return nil, nil
}
func (p *countingLocalRecovery) RecoverVolume(ctx context.Context, id string) (durable.RecoveryReport, error) {
for i := 0; i < p.entries; i++ {
p.visited++
if _, timed := ctx.Deadline(); timed {
p.underDeadline++
}
}
return durable.RecoveryReport{VolumeID: id, Evidence: "local replay completed"}, nil
}
func TestDurableStartup_LocalRecoveryWorkIsOutsideFixedDeadline(t *testing.T) {
for _, entries := range []int{1, 262144} {
t.Run(map[int]string{1: "one", 262144: "one_tib_chunk_count"}[entries], func(t *testing.T) {
p := &countingLocalRecovery{entries: entries}
outcome, _, err := openAndRecoverDurable(p, &spyHost{}, "v1", 10*time.Second)
if err != nil || outcome != durableStartupReady || p.visited != entries {
t.Fatalf("startup=%v err=%v visited=%d want=%d", outcome, err, p.visited, entries)
}
if p.underDeadline != 0 {
t.Fatalf("volume-sized local recovery visited %d/%d entries under a fixed deadline; growing replay must precede the bounded attach operation", p.underDeadline, entries)
}
})
}
}