diff --git a/app/vmauth/main.go b/app/vmauth/main.go index a2f0986bd8..1e15deeaca 100644 --- a/app/vmauth/main.go +++ b/app/vmauth/main.go @@ -357,6 +357,7 @@ func bufferRequestBody(ctx context.Context, r io.ReadCloser, userName string) (i maxBufSize := max(requestBufferSize.IntN(), maxRequestBodySizeToRetry.IntN()) if maxBufSize <= 0 { + // Request buffering is disabled. return r, nil } @@ -792,10 +793,11 @@ func handleConcurrencyLimitError(w http.ResponseWriter, r *http.Request, err err } // bufferedBody serves two purposes: -// 1. Enables request retries when the body size does not exceed maxBodySize -// by fully buffering the body in memory. -// 2. Prevents slow clients from reducing effective server capacity by -// buffering the request body before acquiring a per-user concurrency slot. +// +// 1. It enables request retries when the request body size does not exceed maxBufSize +// by fully buffering the request body in memory. +// 2. It prevents slow clients from reducing effective server capacity +// by buffering the request body before acquiring a per-user concurrency slot. // // See bufferRequestBody for details on how bufferedBody is used. type bufferedBody struct { @@ -819,7 +821,7 @@ func newBufferedBody(r io.ReadCloser, buf []byte, maxBufSize int) *bufferedBody // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/8051 if len(buf) < maxBufSize { - // Read the full request body into buf. + // The full request body has been already read into buf. r = nil } @@ -832,7 +834,7 @@ func newBufferedBody(r io.ReadCloser, buf []byte, maxBufSize int) *bufferedBody // Read implements io.Reader interface. func (bb *bufferedBody) Read(p []byte) (int, error) { if bb.cannotRetry { - return 0, fmt.Errorf("cannot read already closed body") + return 0, fmt.Errorf("cannot read already closed request body") } if bb.bufOffset < len(bb.buf) { n := copy(p, bb.buf[bb.bufOffset:])