From 9c9f2973f80366f6fc61a57a51837635c8e725fd Mon Sep 17 00:00:00 2001 From: ning1875 <907974064@qq.com> Date: Wed, 28 Jul 2021 12:11:36 +0800 Subject: [PATCH] 1. fix remote write err assert on recoverableError (#749) --- backend/prome/prome.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/prome/prome.go b/backend/prome/prome.go index 73f72c31..d6643ec3 100644 --- a/backend/prome/prome.go +++ b/backend/prome/prome.go @@ -226,25 +226,26 @@ func (pd *PromeDataSource) processWrite(payload []byte) { newC := c go func(cc *HttpClient, payload []byte) { sendOk := false - var err error var rec bool + var finalErr error for i := 0; i < retry; i++ { - err = remoteWritePost(cc, payload) + err := remoteWritePost(cc, payload) if err == nil { sendOk = true break } - err, rec = err.(RecoverableError) + _, rec = err.(RecoverableError) + if !rec { + finalErr = err break } - - logger.Warningf("send prome fail: %v", err) + logger.Warningf("[send prome fail recoverableError][retry: %d/%d][err:%v]", i+1, retry, err) time.Sleep(time.Millisecond * 100) } if !sendOk { - logger.Errorf("send prome finally fail: %v", err) + logger.Errorf("send prome finally fail: %v", finalErr) } else { logger.Infof("send to prome %s ok", cc.url.String()) }