Skip to content

Commit

Permalink
app/vmagent/remotewrite: do not retry request immediately on io.ErrUn…
Browse files Browse the repository at this point in the history
…expectedEOF, since this error isn't returned on stale connection

Also, mention the #4139 in comments to the code
in order to simplify further maintenance of this code.

This is a follow-up for 992a1c0
  • Loading branch information
valyala committed Aug 29, 2023
1 parent 0e31415 commit 9d2260e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/vmagent/remotewrite/client.go
Expand Up @@ -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)
}
Expand Down

0 comments on commit 9d2260e

Please sign in to comment.