From 87ee3c57cb9efc9be96b8cf77a796d85f6c3ce93 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 26 Nov 2026 08:24:58 -0800 Subject: [PATCH] s3: keep the EOF read out of the timed body in the put stage test (#13016) * s3: do not delay the EOF read in the put stage timing test TestPutStagesRecordEachStage checks that the storage stage is at least 5ms. That stage is the second chunk's assign wait (20ms) minus the final read that only returns EOF, which slowReader also delayed by 10ms. When busy goroutines hold every P, the reader's wakeup can lag the assign's by as much as a preemption slice, and storage drops below the floor. slowReader now delays only reads that return data, so the EOF read is instant and storage covers the whole assign wait. Co-Authored-By: Claude Opus 5.5 * s3: keep the EOF read out of the timed body in the put stage test Skipping the delay on the EOF read still left that read inside timedBody, so a stall there was subtracted from storage. Feed the upload through an eight-byte limit instead: the final EOF comes from the limit reader without reaching the timed body, so storage always covers the second chunk's full assign wait. slowReader goes back to delaying every read. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- weed/s3api/stats_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/s3api/stats_test.go b/weed/s3api/stats_test.go index 7b651b4863..1e0f892c1f 100644 --- a/weed/s3api/stats_test.go +++ b/weed/s3api/stats_test.go @@ -105,7 +105,7 @@ func TestPutStagesRecordEachStage(t *testing.T) { r = timeBodyReads(r) stages := newPutStages(r) - result, err := stages.upload(context.Background(), r.Body, stagedUploadOption(20*time.Millisecond, nil)) + result, err := stages.upload(context.Background(), io.LimitReader(r.Body, 8), stagedUploadOption(20*time.Millisecond, nil)) require.NoError(t, err) require.Len(t, result.FileChunks, 2) time.Sleep(5 * time.Millisecond)