diff --git a/seaweed-block/cmd/sw-block/chunk_loop.go b/seaweed-block/cmd/sw-block/chunk_loop.go index 8328ea6bec..63c21dd8e4 100644 --- a/seaweed-block/cmd/sw-block/chunk_loop.go +++ b/seaweed-block/cmd/sw-block/chunk_loop.go @@ -105,7 +105,8 @@ func chunkPostLoop(name, statusAddr, route string, timeout time.Duration, body m } sent := time.Now() var out, errb bytes.Buffer - code := chunkPostUntil(name, statusAddr, route, per, sent.Add(per+cushion), body, &out, &errb) + // the client's wait never reaches past the deadline, however late after computing per the request is sent + code := chunkPostUntil(name, statusAddr, route, per, minTime(deadline, sent.Add(per+cushion)), body, &out, &errb) var e chunkErrBody // repeated only after a retryable or outcome_unknown answer (INV-CLI-CHUNK-LOOP-001) retry := code != ops.VolumeStatusExitOK && json.Unmarshal(out.Bytes(), &e) == nil && e.Code != "" && diff --git a/seaweed-block/cmd/sw-block/chunk_request_loop_test.go b/seaweed-block/cmd/sw-block/chunk_request_loop_test.go index 3277e78f18..7e676b8fcf 100644 --- a/seaweed-block/cmd/sw-block/chunk_request_loop_test.go +++ b/seaweed-block/cmd/sw-block/chunk_request_loop_test.go @@ -207,6 +207,14 @@ func runChunkWithin(t *testing.T, limit time.Duration, args ...string) (int, str case r := <-done: return r.code, r.out, r.err case <-time.After(limit): + // join the command (bounded) before the earlier cleanups restore the package globals it reads; cleanups run + // last-registered first + t.Cleanup(func() { + select { + case <-done: + case <-time.After(10 * time.Second): + } + }) t.Fatalf("the command did not return within %v: the loop does not end at its --timeout", limit) return 0, "", "" }