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

Merged
merged 2 commits into from
Nov 2, 2023
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 @@ -105,7 +105,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
3 changes: 2 additions & 1 deletion br/pkg/pdutil/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
maxMsgSize = int(128 * units.MiB) // pd.ScanRegion may return a large response
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 @@ -157,6 +157,7 @@ func pdRequestWithCode(
resp *http.Response
)
count := 0
// the total retry duration: 120*1 = 2min
for {
req, err = http.NewRequestWithContext(ctx, method, reqURL, body)
if err != nil {
Expand Down
Loading