-
Notifications
You must be signed in to change notification settings - Fork 314
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
cluster: refine the process of getting latest store info from pd #1016
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1016 +/- ##
==========================================
- Coverage 55.70% 51.88% -3.83%
==========================================
Files 279 280 +1
Lines 19744 19734 -10
==========================================
- Hits 10999 10238 -761
- Misses 7036 7879 +843
+ Partials 1709 1617 -92
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
pkg/cluster/api/pdapi.go
Outdated
if err != nil { | ||
return false, err | ||
} | ||
if storeInfo == nil { |
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.
If storeInfo == nil, the err will not be nil. So I think this code is not necessary。
pkg/cluster/api/pdapi.go
Outdated
} | ||
|
||
if storeID == 0 { | ||
if storeInfo == nil { |
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.
ditto
@@ -614,23 +617,24 @@ func (pc *PDClient) DelStore(host string, retryOpt *utils.RetryOption) error { | |||
} | |||
} | |||
if err := utils.Retry(func() error { | |||
currStores, err := pc.GetStores() | |||
currStore, err := pc.GetCurrentStore(host) |
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.
The err will not be nil if we don't found target store, and the Retry will retry the action and fail again
pkg/cluster/api/pdapi.go
Outdated
if err != nil { | ||
return err | ||
} | ||
if currStore == nil { |
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.
If we should check if currStore ==nil, I think it's better not return err in GetCurrentStore(host) while not found store
pkg/cluster/spec/tikv.go
Outdated
} | ||
if latestStore != nil { | ||
return latestStore.Store.StateName | ||
if store == nil { |
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.
The store will not be nil. Maybe is NoStoreErr?
dab15df
to
9f1f97a
Compare
/lgtm |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 9f1f97a
|
* cluster/pdapi: refine the process of getting latest store * cluster: minor optimization of output when evicting store leaders * cluster/api: refactor to use a predefined error type when store not found
What problem does this PR solve?
This is a following up of #1011
What is changed and how it works?
Some more functions than checking store state are querying for store info of the latest / current store from PD that matching a specific host, so use a dedicated function to archive that purpose and implement the workaround of non-monotonic ID issue of PD there.
Check List
Tests
Code changes
Related changes
Release notes: