Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdutil/backend: enlarge max retry time and fix nested retriable error (#48210) #48227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion br/pkg/lightning/common/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ func isSingleRetryableError(err error) bool {
if nerr.Timeout() {
return true
}
if syscallErr, ok := goerrors.Unwrap(err).(*os.SyscallError); ok {
// the error might be nested, such as *url.Error -> *net.OpError -> *os.SyscallError
var syscallErr *os.SyscallError
if goerrors.As(nerr, &syscallErr) {
return syscallErr.Err == syscall.ECONNREFUSED || syscallErr.Err == syscall.ECONNRESET
}
return false
Expand Down
4 changes: 4 additions & 0 deletions br/pkg/lightning/common/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io"
"net"
"net/url"
"testing"

"github.com/go-sql-driver/mysql"
Expand Down Expand Up @@ -66,6 +67,9 @@ func TestIsRetryableError(t *testing.T) {
_, err := net.Dial("tcp", "localhost:65533")
require.Error(t, err)
require.True(t, IsRetryableError(err))
// wrap net.OpErr inside url.Error
urlErr := &url.Error{Op: "post", Err: err}
require.True(t, IsRetryableError(urlErr))

// MySQL Errors
require.False(t, IsRetryableError(&mysql.MySQLError{}))
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/pdutil/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ const (
pauseTimeout = 5 * time.Minute

// pd request retry time when connection fail
pdRequestRetryTime = 10

pdRequestRetryTime = 120
// set max-pending-peer-count to a large value to avoid scatter region failed.
maxPendingPeerUnlimited uint64 = math.MaxInt32
)
Expand Down Expand Up @@ -170,6 +169,7 @@ func pdRequestWithCode(
}
var resp *http.Response
count := 0
// the total retry duration: 120*1 = 2min
for {
resp, err = cli.Do(req) //nolint:bodyclose
count++
Expand Down