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

cluster: refine the process of getting latest store info from pd #1016

Merged
merged 3 commits into from
Dec 28, 2020

Conversation

AstroProfundis
Copy link
Contributor

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

  • Manual test (add detailed scripts or steps below)

Code changes

  • Has exported function/method change

Related changes

  • Need to cherry-pick to the release branch

Release notes:

NONE

@AstroProfundis AstroProfundis added type/enhancement Categorizes issue or PR as related to an enhancement. type/bug-fix Categorizes PR as a bug-fix category/stability Categorizes issue or PR as a stability enhancement. labels Dec 25, 2020
@AstroProfundis AstroProfundis self-assigned this Dec 25, 2020
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 25, 2020
@codecov-io
Copy link

codecov-io commented Dec 25, 2020

Codecov Report

Merging #1016 (9f1f97a) into master (357cd71) will decrease coverage by 3.82%.
The diff coverage is 48.64%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
cluster 38.41% <43.24%> (-5.23%) ⬇️
dm 23.97% <0.00%> (+<0.01%) ⬆️
integrate 46.11% <43.24%> (-3.87%) ⬇️
playground 20.31% <0.00%> (+<0.01%) ⬆️
tiup 16.48% <0.00%> (+0.01%) ⬆️
unittest 22.28% <5.40%> (-0.73%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/cluster/spec/tikv.go 56.63% <18.18%> (-0.45%) ⬇️
pkg/cluster/api/pdapi.go 59.93% <51.72%> (-1.37%) ⬇️
pkg/cluster/api/error.go 80.00% <80.00%> (ø)
components/cluster/command/check.go 6.27% <0.00%> (-73.27%) ⬇️
pkg/cluster/task/limits.go 0.00% <0.00%> (-68.75%) ⬇️
pkg/cluster/task/sysctl.go 0.00% <0.00%> (-66.67%) ⬇️
components/cluster/command/audit.go 27.27% <0.00%> (-54.55%) ⬇️
pkg/cluster/operation/check.go 0.00% <0.00%> (-53.07%) ⬇️
pkg/cluster/manager/patch.go 0.00% <0.00%> (-51.81%) ⬇️
pkg/cluster/task/rmdir.go 0.00% <0.00%> (-50.00%) ⬇️
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 357cd71...9f1f97a. Read the comment docs.

if err != nil {
return false, err
}
if storeInfo == nil {
Copy link
Member

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。

}

if storeID == 0 {
if storeInfo == nil {
Copy link
Member

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)
Copy link
Member

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

if err != nil {
return err
}
if currStore == nil {
Copy link
Member

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

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 28, 2020
}
if latestStore != nil {
return latestStore.Store.StateName
if store == nil {
Copy link
Member

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?

@lucklove
Copy link
Member

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 28, 2020
@lucklove
Copy link
Member

/merge

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 28, 2020
@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 9f1f97a

@ti-chi-bot ti-chi-bot merged commit 4571217 into pingcap:master Dec 28, 2020
@AstroProfundis AstroProfundis deleted the fix-3303 branch December 28, 2020 10:10
@lucklove lucklove added this to the v1.3.1 milestone Dec 31, 2020
lucklove pushed a commit that referenced this pull request Dec 31, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/stability Categorizes issue or PR as a stability enhancement. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/bug-fix Categorizes PR as a bug-fix type/enhancement Categorizes issue or PR as related to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants