From 9d2260ed3c9f8e191a7f26654b2b44abb2d3015f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 29 Aug 2023 09:36:03 +0200 Subject: [PATCH] app/vmagent/remotewrite: do not retry request immediately on io.ErrUnexpectedEOF, since this error isn't returned on stale connection Also, mention the https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4139 in comments to the code in order to simplify further maintenance of this code. This is a follow-up for 992a1c0a3a2e4bb6ac9ad9be7c9621a3ac850a26 --- app/vmagent/remotewrite/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/vmagent/remotewrite/client.go b/app/vmagent/remotewrite/client.go index 1b5399dc0c70..56d0f7210f94 100644 --- a/app/vmagent/remotewrite/client.go +++ b/app/vmagent/remotewrite/client.go @@ -325,10 +325,11 @@ func (c *client) runWorker() { func (c *client) doRequest(url string, body []byte) (*http.Response, error) { req := c.newRequest(url, body) resp, err := c.hc.Do(req) - if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { + if err != nil && errors.Is(err, io.EOF) { // it is likely connection became stale. // So we do one more attempt in hope request will succeed. // If not, the error should be handled by the caller as usual. + // This should help with https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4139 req = c.newRequest(url, body) resp, err = c.hc.Do(req) }