From c2ab4bf16d564a8ecdc8345d63794cf9cf6973be Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:01:33 +0800 Subject: [PATCH] feat(prover): add failure retry on rpc error (#994) Co-authored-by: colinlyguo --- common/version/version.go | 2 +- prover/client/client.go | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/common/version/version.go b/common/version/version.go index 11a222d8e8..c32707b1f1 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.3.36" +var tag = "v4.3.37" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/prover/client/client.go b/prover/client/client.go index 94e9449a1d..9845c64b32 100644 --- a/prover/client/client.go +++ b/prover/client/client.go @@ -4,7 +4,6 @@ import ( "context" "crypto/ecdsa" "fmt" - "net/http" "sync" "time" @@ -35,13 +34,13 @@ func NewCoordinatorClient(cfg *config.CoordinatorConfig, proverName string, priv SetRetryCount(cfg.RetryCount). SetRetryWaitTime(time.Duration(cfg.RetryWaitTimeSec) * time.Second). SetBaseURL(cfg.BaseURL). - AddRetryCondition(func(r *resty.Response, _ error) bool { - // Check for HTTP 5xx errors, e.g., coordinator is restarting. - if r.StatusCode() >= http.StatusInternalServerError { - log.Warn("Received unexpected HTTP response. Retrying...", "status code", r.StatusCode()) + AddRetryAfterErrorCondition(). + AddRetryCondition(func(response *resty.Response, err error) bool { + if err != nil { + log.Warn("Encountered an error while sending the request. Retrying...", "error", err) return true } - return false + return response.IsError() }) log.Info("successfully initialized prover client",