From 3b3b3e01a84642f5002af5f907df9ecc9d744a9d Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 9 Jan 2024 17:26:51 +0800 Subject: [PATCH] Copy new Backoffer for each request Signed-off-by: JmPotato --- client/http/client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/http/client.go b/client/http/client.go index 863c8bfcbb5..ac14de50b33 100644 --- a/client/http/client.go +++ b/client/http/client.go @@ -183,11 +183,13 @@ func (ci *clientInner) requestWithRetry( if reqInfo.bo == nil { return execFunc() } + // Copy a new backoffer for each request. + bo := *reqInfo.bo // Backoffer also needs to check the status code to determine whether to retry. - reqInfo.bo.SetRetryableChecker(func(err error) bool { + bo.SetRetryableChecker(func(err error) bool { return err != nil && !noNeedRetry(statusCode) }) - return reqInfo.bo.Exec(ctx, execFunc) + return bo.Exec(ctx, execFunc) } func noNeedRetry(statusCode int) bool {