mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
fix(sw-block): clamp each request's client wait to the loop's deadline
The client's wait for an answer was sent + per + cushion, with per computed before sent was sampled: a pause between the two moved the wait past the loop's deadline. It is now min(deadline, sent + per + cushion), so it never reaches past --timeout (INV-CLI-CHUNK-LOOP-003). Test isolation: when runChunkWithin's bound fails a test, it now joins the command (bounded) before the earlier cleanups restore the package globals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d20b61c299
commit
073bb08ddf
2 files changed
+10
-1
No files matched your search
@@ -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 != "" &&
|
||||
|
||||
@@ -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, "", ""
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user