From 09346d4de9ad1724aa9044025c22806ae4f68989 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 23 Nov 2026 13:10:59 -0800 Subject: [PATCH 1/4] test(blockvolume): F1 resends a snapshot refused for a busy host slot N volumes snapshot at the same instant against fewer host slots; the slot refusals (host_slot_busy, capture_refused from the host limiter) are retryable by contract. F1 now resends them with the same request id every 250 ms for up to 120 s, records the count per round, and keeps the wait in the request-to-commit time the starvation bound checks. Co-Authored-By: Claude Opus 5.5 --- .../snapshot_ladder_f1_integration_test.go | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go index 017137de1d..54c048b220 100644 --- a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go +++ b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go @@ -110,6 +110,7 @@ type f1Round struct { UploadedChunks int `json:"uploaded_chunks"` UploadedBytes int64 `json:"uploaded_bytes"` HostSlotWaits uint64 `json:"host_slot_waits"` + SlotRetries int `json:"snapshot_slot_refusals_retried"` RestoreMs float64 `json:"restore_ms"` RestoreExact bool `json:"restore_exact"` LoadPrefix int `json:"load_prefix_blocks"` @@ -268,6 +269,28 @@ func f1Restore(t *testing.T, env *handoffEnv, src, snap, target string) *daemon // longer than this by a cut fails the rung. const f1CommandDeadline = 30 * time.Second +// A snapshot refused because every host slot is held is resent with its +// request id every f1SlotRetryPause, for at most f1SlotRetryBound from its +// first request; its request-to-commit time includes the waits. +const ( + f1SlotRetryPause = 250 * time.Millisecond + f1SlotRetryBound = 120 * time.Second +) + +// f1SlotRefusal reports whether a failed snapshot's error body is a +// retryable refusal for a busy host slot. +func f1SlotRefusal(stdout string) bool { + var body struct { + Code string `json:"code"` + Message string `json:"message"` + Retryable bool `json:"retryable"` + } + if json.Unmarshal([]byte(strings.TrimSpace(stdout)), &body) != nil || !body.Retryable { + return false + } + return body.Code == "host_slot_busy" || body.Code == "capture_refused" && strings.Contains(body.Message, "hostlimit: no background slot") +} + // f1Block is one deterministic 4096-byte block (pattern needs a length that // divides 4096; these labels do not, so the block is filled explicitly). func f1Block(vol string, round int, kind string, lba uint64) []byte { @@ -359,6 +382,7 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro start, end time.Time out, err string code int + retries int } res := make([]snapRes, len(vols)) var sg sync.WaitGroup @@ -369,7 +393,18 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro defer sg.Done() <-gate res[i].start = time.Now() - res[i].out, res[i].err, res[i].code = env.h.run(t, "ops", "chunk", "snapshot", "--volume", v.id, "--status-addr", env.hosts[v.node].status, "--name", fmt.Sprintf("f1-r%d", round)) + // A refusal for a busy host slot is retryable by contract: resend + // it with the same request id, as an operator would, within a bound. + request := fmt.Sprintf("f1-r%d-%s", round, v.id) + for { + res[i].out, res[i].err, res[i].code = env.h.run(t, "ops", "chunk", "snapshot", "--volume", v.id, "--status-addr", env.hosts[v.node].status, + "--name", fmt.Sprintf("f1-r%d", round), "--request-id", request) + if res[i].code == 0 || !f1SlotRefusal(res[i].out) || time.Since(res[i].start) > f1SlotRetryBound { + break + } + res[i].retries++ + time.Sleep(f1SlotRetryPause) + } res[i].end = time.Now() }(i, v) } @@ -393,6 +428,7 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro continue } r.SnapshotMs = ms(res[i].end.Sub(res[i].start)) + r.SlotRetries = res[i].retries f1Latencies(&r, w.samples, res[i].start, res[i].end) if r.WritesIn == 0 { rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: no load write was issued inside the snapshot window", v.id, round)) From 58c5b6829464cf087f0fe34dba81cbca4313d802 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 23 Nov 2026 13:16:41 -0800 Subject: [PATCH 2/4] test(blockvolume): F1 retry bound = the snapshot command's deadline; not admitted fails; not_run restore rows The retry bound is the snapshot command's 60 s operation bound (F1_SLOT_RETRY_SECONDS, 0 = no retry, the negative control). A snapshot still refused at the bound fails the rung as not admitted; restore_exact reads "not_run" for it, never false. The slot wait is reported and the write window starts at the admitted attempt. Co-Authored-By: Claude Opus 5.5 --- .../snapshot_ladder_f1_integration_test.go | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go index 54c048b220..da82203aaa 100644 --- a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go +++ b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go @@ -54,6 +54,7 @@ type f1Config struct { Volumes, Rounds int WriteSeconds int HostLimitDir string + SlotRetryBound time.Duration Slots int Report string LedgerBlocksPerRnd int @@ -78,7 +79,7 @@ func f1ConfigFromEnv(t *testing.T) f1Config { } c := f1Config{Volumes: num("F1_VOLUMES", 10), Rounds: num("F1_ROUNDS", 3), WriteSeconds: num("F1_WRITE_SECONDS", 120), HostLimitDir: os.Getenv("F1_HOST_LIMIT_DIR"), Slots: num("F1_HOST_LIMIT_SLOTS", hostlimit.DefaultConfig("").NormalSlots), - Report: os.Getenv("F1_REPORT"), LedgerBlocksPerRnd: 64, LoadSpan: num("F1_LOAD_SPAN", 8192)} + SlotRetryBound: time.Duration(num("F1_SLOT_RETRY_SECONDS", 60)) * time.Second, Report: os.Getenv("F1_REPORT"), LedgerBlocksPerRnd: 64, LoadSpan: num("F1_LOAD_SPAN", 8192)} if v := os.Getenv("F1_CONTROL_PAUSE_SECONDS"); v != "" { c.ControlPauseSecs = num("F1_CONTROL_PAUSE_SECONDS", 0) } @@ -111,8 +112,11 @@ type f1Round struct { UploadedBytes int64 `json:"uploaded_bytes"` HostSlotWaits uint64 `json:"host_slot_waits"` SlotRetries int `json:"snapshot_slot_refusals_retried"` + SlotWaitMs float64 `json:"snapshot_slot_wait_ms"` RestoreMs float64 `json:"restore_ms"` - RestoreExact bool `json:"restore_exact"` + // RestoreExact is true or false for a snapshot that ran, "not_run" for + // one that was never admitted. + RestoreExact any `json:"restore_exact"` LoadPrefix int `json:"load_prefix_blocks"` WritesIn int `json:"writes_in_window"` WritesOut int `json:"writes_outside_window"` @@ -270,12 +274,12 @@ func f1Restore(t *testing.T, env *handoffEnv, src, snap, target string) *daemon const f1CommandDeadline = 30 * time.Second // A snapshot refused because every host slot is held is resent with its -// request id every f1SlotRetryPause, for at most f1SlotRetryBound from its -// first request; its request-to-commit time includes the waits. -const ( - f1SlotRetryPause = 250 * time.Millisecond - f1SlotRetryBound = 120 * time.Second -) +// request id every f1SlotRetryPause, for at most cfg.SlotRetryBound from its +// first request (the snapshot command's operation bound, its default +// --timeout of 60 s; F1_SLOT_RETRY_SECONDS=0 turns the retry off, the +// negative control). Its request-to-commit time includes the waits; the +// write window starts at the admitted attempt. +const f1SlotRetryPause = 250 * time.Millisecond // f1SlotRefusal reports whether a failed snapshot's error body is a // retryable refusal for a busy host slot. @@ -380,6 +384,7 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro type snapRes struct { start, end time.Time + admitted time.Time // the start of the attempt that was not refused out, err string code int retries int @@ -397,9 +402,10 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro // it with the same request id, as an operator would, within a bound. request := fmt.Sprintf("f1-r%d-%s", round, v.id) for { + res[i].admitted = time.Now() res[i].out, res[i].err, res[i].code = env.h.run(t, "ops", "chunk", "snapshot", "--volume", v.id, "--status-addr", env.hosts[v.node].status, "--name", fmt.Sprintf("f1-r%d", round), "--request-id", request) - if res[i].code == 0 || !f1SlotRefusal(res[i].out) || time.Since(res[i].start) > f1SlotRetryBound { + if res[i].code == 0 || !f1SlotRefusal(res[i].out) || time.Since(res[i].start) > cfg.SlotRetryBound { break } res[i].retries++ @@ -416,20 +422,25 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro out := make([]f1Round, len(vols)) for i, v := range vols { - r := f1Round{Volume: v.id, Round: round} + r := f1Round{Volume: v.id, Round: round, RestoreExact: "not_run", SlotRetries: res[i].retries} w := ws[i] if w.err != nil { rep.WriteErrors++ rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: write error: %v", v.id, round, w.err)) } + if res[i].code != 0 && f1SlotRefusal(res[i].out) { + rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: snapshot not admitted within %v (%d slot refusals retried): %s", v.id, round, cfg.SlotRetryBound, res[i].retries, firstLine(res[i].out))) + out[i] = r + continue + } if res[i].code != 0 { rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: snapshot exit %d: %s %s", v.id, round, res[i].code, res[i].out, res[i].err)) out[i] = r continue } r.SnapshotMs = ms(res[i].end.Sub(res[i].start)) - r.SlotRetries = res[i].retries - f1Latencies(&r, w.samples, res[i].start, res[i].end) + r.SlotWaitMs = ms(res[i].admitted.Sub(res[i].start)) + f1Latencies(&r, w.samples, res[i].admitted, res[i].end) if r.WritesIn == 0 { rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: no load write was issued inside the snapshot window", v.id, round)) } @@ -439,9 +450,10 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro rs := time.Now() rd := f1Restore(t, env, v.id, fmt.Sprintf("f1-r%d", round), target) r.RestoreMs = ms(time.Since(rs)) - r.RestoreExact, r.LoadPrefix = f1Verify(t, env, cfg, v.id, target, round, w.written) + exact, prefix := f1Verify(t, env, cfg, v.id, target, round, w.written) + r.RestoreExact, r.LoadPrefix = exact, prefix rd.term(t, 60*time.Second) - if !r.RestoreExact { + if !exact { rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: the restored snapshot is not the volume at its point", v.id, round)) } out[i] = r From f4f4d0da91091fbeb636e6a37f46b86d8f879541 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 23 Nov 2026 13:22:06 -0800 Subject: [PATCH 3/4] test(blockvolume): F1_SLOT_RETRY_SECONDS accepts 0 (the negative control) Co-Authored-By: Claude Opus 5.5 --- .../blockvolume/snapshot_ladder_f1_integration_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go index da82203aaa..6df15841f1 100644 --- a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go +++ b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go @@ -77,9 +77,17 @@ func f1ConfigFromEnv(t *testing.T) f1Config { } return def } + retry := 60 // the snapshot command's default --timeout; 0 = no retry (the negative control) + if v := os.Getenv("F1_SLOT_RETRY_SECONDS"); v != "" { + n, err := strconv.Atoi(v) + if err != nil || n < 0 { + t.Fatalf("F1_SLOT_RETRY_SECONDS=%q: want a whole number of seconds, 0 or more", v) + } + retry = n + } c := f1Config{Volumes: num("F1_VOLUMES", 10), Rounds: num("F1_ROUNDS", 3), WriteSeconds: num("F1_WRITE_SECONDS", 120), HostLimitDir: os.Getenv("F1_HOST_LIMIT_DIR"), Slots: num("F1_HOST_LIMIT_SLOTS", hostlimit.DefaultConfig("").NormalSlots), - SlotRetryBound: time.Duration(num("F1_SLOT_RETRY_SECONDS", 60)) * time.Second, Report: os.Getenv("F1_REPORT"), LedgerBlocksPerRnd: 64, LoadSpan: num("F1_LOAD_SPAN", 8192)} + Report: os.Getenv("F1_REPORT"), LedgerBlocksPerRnd: 64, LoadSpan: num("F1_LOAD_SPAN", 8192), SlotRetryBound: time.Duration(retry) * time.Second} if v := os.Getenv("F1_CONTROL_PAUSE_SECONDS"); v != "" { c.ControlPauseSecs = num("F1_CONTROL_PAUSE_SECONDS", 0) } From ceca03943de78978a03a9eb02ca44a6c18b80b12 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 23 Nov 2026 13:24:42 -0800 Subject: [PATCH 4/4] test(blockvolume): F1's not-admitted failure carries the whole refusal body Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/snapshot_ladder_f1_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go index 6df15841f1..b4d2a8b560 100644 --- a/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go +++ b/seaweed-block/cmd/blockvolume/snapshot_ladder_f1_integration_test.go @@ -437,7 +437,7 @@ func f1RunRound(t *testing.T, env *handoffEnv, cfg f1Config, vols []f1Volume, ro rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: write error: %v", v.id, round, w.err)) } if res[i].code != 0 && f1SlotRefusal(res[i].out) { - rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: snapshot not admitted within %v (%d slot refusals retried): %s", v.id, round, cfg.SlotRetryBound, res[i].retries, firstLine(res[i].out))) + rep.Failures = append(rep.Failures, fmt.Sprintf("%s round %d: snapshot not admitted within %v (%d slot refusals retried): %s", v.id, round, cfg.SlotRetryBound, res[i].retries, strings.Join(strings.Fields(res[i].out), " "))) out[i] = r continue }