mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
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 992a1c0a3a
This commit is contained in:
parent
cf2a4f996d
commit
b3d5f4a305
1 changed files with 2 additions and 1 deletions
|
@ -325,10 +325,11 @@ func (c *client) runWorker() {
|
||||||
func (c *client) doRequest(url string, body []byte) (*http.Response, error) {
|
func (c *client) doRequest(url string, body []byte) (*http.Response, error) {
|
||||||
req := c.newRequest(url, body)
|
req := c.newRequest(url, body)
|
||||||
resp, err := c.hc.Do(req)
|
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.
|
// it is likely connection became stale.
|
||||||
// So we do one more attempt in hope request will succeed.
|
// So we do one more attempt in hope request will succeed.
|
||||||
// If not, the error should be handled by the caller as usual.
|
// 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)
|
req = c.newRequest(url, body)
|
||||||
resp, err = c.hc.Do(req)
|
resp, err = c.hc.Do(req)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue