-
Notifications
You must be signed in to change notification settings - Fork 728
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
*: fix region stats check #7748
Conversation
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
[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 submitting an approval review. |
/run-check-issue-triage-complete |
if origin.GetLeader().GetId() == 0 { | ||
isNew = true | ||
} else if log.GetLevel() <= zap.InfoLevel { | ||
if log.GetLevel() <= zap.InfoLevel { | ||
info("leader changed", |
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.
Will it print leader 0?
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #7748 +/- ##
==========================================
- Coverage 73.47% 73.44% -0.04%
==========================================
Files 432 432
Lines 47842 47843 +1
==========================================
- Hits 35151 35136 -15
- Misses 9648 9666 +18
+ Partials 3043 3041 -2
Flags with carried forward coverage won't be shown. Click here to find out more. |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
pkg/statistics/region_collection.go
Outdated
@@ -240,10 +250,10 @@ func (r *RegionStatistics) Observe(region *core.RegionInfo, stores []*core.Store | |||
} | |||
} | |||
// Remove the info if any of the conditions are not met any more. | |||
if oldIndex, ok := r.index[regionID]; ok { | |||
deleteIndex = oldIndex &^ peerTypeIndex | |||
if oldIndex, ok := r.index[regionID]; ok && oldIndex > 0 { |
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 oldIndex > 0
0 for region state feels a bit weird, do you think we need to add a state name to 0? Like notRecord
or something.
and maybe better != 0
?
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 bit operations. !=
doesn't seem to be used very often
pkg/core/region.go
Outdated
@@ -718,19 +724,16 @@ func GenerateRegionGuideFunc(enableLog bool) RegionGuideFunc { | |||
} | |||
// Save to storage if meta is updated. | |||
// Save to cache if meta or leader is updated, or contains any down/pending peer. | |||
// Mark isNew if the region in cache does not have leader. | |||
return func(region, origin *RegionInfo) (isNew, saveKV, saveCache, needSync bool) { | |||
// Now, no need to hold `isNew` because `saveCache` must be true if the region in cache does not have leader. |
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.
maybe can move this statement to pr description
// Now, no need to hold `isNew` because `saveCache` must be true if the region in cache does not have leader. |
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.
Got it. But I think we can keep this comment in code.
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.
Oh 😯 I mean, after your code merged, isNew
is a word which doesn't exist and could be confused others.
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.
OK
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
/merge |
@CabinfeverB: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: cf03d8c
|
In response to a cherrypick label: new pull request created to branch |
close tikv#7728 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
close tikv#7728 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
close tikv#7728 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
close tikv#7728 Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
close #7728 Signed-off-by: husharp <jinhao.hu@pingcap.com> Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com> Co-authored-by: husharp <jinhao.hu@pingcap.com> Co-authored-by: Yongbo Jiang <cabinfeveroier@gmail.com> Co-authored-by: Cabinfever_B <cabinfeveroier@gmail.com>
What problem does this PR solve?
Issue Number: Close #7728
What is changed and how does it work?
isNew
is useless because region source is inexact when leader transfer and no sync. Now, no need to holdisNew
becausesaveCache
must be true if the region in cache does not have leader.Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note