-
Notifications
You must be signed in to change notification settings - Fork 102
Conversation
pkg/pdutil/pd.go
Outdated
time.Sleep(time.Duration(i) * time.Second) | ||
continue | ||
} | ||
defer resp.Body.Close() |
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.
remove defer 🤔️
pkg/pdutil/pd.go
Outdated
resp, reqErr = cli.Do(req) | ||
if err != nil { | ||
log.Warn("pd request fail, retry", zap.Int("retry time", i), zap.Error(reqErr)) | ||
time.Sleep(time.Duration(i) * time.Second) |
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.
I think just sleep 1 second is better. then if there is something wrong with PD. we can wait at most 10 seconds.
Co-authored-by: 3pointer <qdlc2010@gmail.com>
pkg/pdutil/pd.go
Outdated
if resp.StatusCode != http.StatusOK { | ||
if resp.StatusCode >= 500 { | ||
log.Warn("pd request fail, retry", zap.Int("retry time", i), zap.String("State", resp.Status)) | ||
time.Sleep(time.Second) |
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.
Seems after the retry, the old response won't be closed? 🤔
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.
fixed
/run-integration-tests |
/lgtm |
/lgtm |
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: dc897dc
|
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #1092. |
In response to a cherrypick label: new pull request could not be created: failed to create pull request against pingcap/br#release-4.0 from head ti-chi-bot:cherry-pick-1088-to-release-4.0: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-1088-to-release-4.0."}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"} |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #1093. |
In response to a cherrypick label: new pull request could not be created: failed to create pull request against pingcap/br#release-5.0 from head ti-chi-bot:cherry-pick-1088-to-release-5.0: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-1088-to-release-5.0."}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"} |
What problem does this PR solve?
When client send a request to pd failed due to some recoverable server faults or network issues, it is better to retry than to return error.
What is changed and how it works?
Add pd request retry logic on
pdRequest
function inpkg/pdutil/pd.go
file.Check List
Tests
Code changes
Release Note