-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Add retry for dialPumpClient #4879
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4faaa86
add retry for dialPumpClient
XuHuaiyu 2f323e0
remove useless code
XuHuaiyu c4fd5c5
Merge branch 'master' of https://github.com/pingcap/tidb into issue4848
XuHuaiyu c66909a
address comment
XuHuaiyu 515dfd0
Merge branch 'master' of https://github.com/pingcap/tidb into issue4848
XuHuaiyu f94ac43
Merge branch 'master' into issue4848
shenli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,13 +37,12 @@ import ( | |
"github.com/pingcap/tidb/terror" | ||
"github.com/pingcap/tidb/util" | ||
"github.com/pingcap/tidb/util/types" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
// Engine prefix name | ||
const ( | ||
EngineGoLevelDBMemory = "memory://" | ||
defaultMaxRetries = 30 | ||
retryInterval uint64 = 500 | ||
EngineGoLevelDBMemory = "memory://" | ||
) | ||
|
||
type domainMap struct { | ||
|
@@ -66,7 +65,7 @@ func (dm *domainMap) Get(store kv.Storage) (d *domain.Domain, err error) { | |
ddlLease = schemaLease | ||
statisticLease = statsLease | ||
} | ||
err = util.RunWithRetry(defaultMaxRetries, retryInterval, func() (retry bool, err1 error) { | ||
err = util.RunWithRetry(util.DefaultMaxRetries, util.RetryInterval, func() (retry bool, err1 error) { | ||
log.Infof("store %v new domain, ddl lease %v, stats lease %d", store.UUID(), ddlLease, statisticLease) | ||
factory := createSessionFunc(store) | ||
sysFactory := createSessionWithDomainFunc(store) | ||
|
@@ -232,7 +231,7 @@ func RegisterLocalStore(name string, driver engine.Driver) error { | |
// | ||
// The engine should be registered before creating storage. | ||
func NewStore(path string) (kv.Storage, error) { | ||
return newStoreWithRetry(path, defaultMaxRetries) | ||
return newStoreWithRetry(path, util.DefaultMaxRetries) | ||
} | ||
|
||
func newStoreWithRetry(path string, maxRetries int) (kv.Storage, error) { | ||
|
@@ -248,13 +247,29 @@ func newStoreWithRetry(path string, maxRetries int) (kv.Storage, error) { | |
} | ||
|
||
var s kv.Storage | ||
err1 := util.RunWithRetry(maxRetries, retryInterval, func() (bool, error) { | ||
err1 := util.RunWithRetry(maxRetries, util.RetryInterval, func() (bool, error) { | ||
log.Infof("new store") | ||
s, err = d.Open(path) | ||
return kv.IsRetryableError(err), err | ||
}) | ||
return s, errors.Trace(err1) | ||
} | ||
|
||
// DialPumpClientWithRetry tries to dial to binlogSocket, | ||
// if any error happens, it will try to re-dial, | ||
// or return this error when timeout. | ||
func DialPumpClientWithRetry(binlogSocket string, clientCon *grpc.ClientConn, maxRetries int, dialerOpt grpc.DialOption) error { | ||
return util.RunWithRetry(maxRetries, util.RetryInterval, func() (bool, error) { | ||
log.Infof("setup binlog client") | ||
var err error | ||
clientCon, err = grpc.Dial(binlogSocket, grpc.WithInsecure(), dialerOpt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should log something if meet this error. |
||
if err != nil { | ||
log.Infof("error happen when setting binlog client: %s", errors.ErrorStack(err)) | ||
} | ||
return true, errors.Trace(err) | ||
}) | ||
} | ||
|
||
var queryStmtTable = []string{"explain", "select", "show", "execute", "describe", "desc", "admin"} | ||
|
||
func trimSQL(sql string) string { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we log this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For recording this process.