-
Notifications
You must be signed in to change notification settings - Fork 726
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
scheduler: add leader verify in balance-region scheduler #2966
Conversation
Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
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.
rest LGTM
pkg/mock/mockcluster/mockcluster.go
Outdated
@@ -535,7 +540,7 @@ func (mc *Cluster) UpdateStoreStatus(id uint64) { | |||
} | |||
|
|||
func (mc *Cluster) newMockRegionInfo(regionID uint64, leaderStoreID uint64, followerStoreIDs ...uint64) *core.RegionInfo { | |||
return mc.MockRegionInfo(regionID, leaderStoreID, followerStoreIDs, []uint64{}, nil) | |||
return mc.MockRegionInfo(regionID, &leaderStoreID, followerStoreIDs, []uint64{}, 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.
When does nil
need to be passed in here? In addition, 0
can also mean that store does not exist.
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 check 0 is better.
Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
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.
rest LGTM
pkg/mock/mockcluster/mockcluster.go
Outdated
@@ -583,8 +584,12 @@ func (mc *Cluster) MockRegionInfo(regionID uint64, leaderStoreID uint64, | |||
EndKey: []byte(fmt.Sprintf("%20d", regionID+1)), | |||
RegionEpoch: epoch, | |||
} | |||
leader, _ := mc.AllocPeer(leaderStoreID) | |||
region.Peers = []*metapb.Peer{leader} | |||
region.Peers = []*metapb.Peer{} |
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.
region.Peers = []*metapb.Peer{} |
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.
updated.
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 rest LGTM
server/schedulers/balance_region.go
Outdated
@@ -173,6 +173,12 @@ func (s *balanceRegionScheduler) Schedule(cluster opt.Cluster) []*operator.Opera | |||
schedulerCounter.WithLabelValues(s.GetName(), "region-hot").Inc() | |||
continue | |||
} | |||
// Check region whether have leader | |||
if region.GetLeader() == nil { | |||
log.Debug("region have no leader", zap.String("scheduler", s.GetName()), zap.Uint64("region-id", region.GetID())) |
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.
it may be warn
?
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.
updated.
Signed-off-by: Song Gao <[email protected]>
/merge |
@Yisaer Oops! auto merge is restricted to Committers of the SIG.See the corresponding SIG page for more information. Related SIG: scheduling(slack). |
/merge |
/run-all-tests |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-4.0 in PR #2994 |
* cherry pick #2966 to release-4.0 Signed-off-by: ti-srebot <[email protected]> * fix conflict Signed-off-by: Song Gao <[email protected]> * fix test Signed-off-by: Song Gao <[email protected]> Co-authored-by: Song Gao <[email protected]> Co-authored-by: lhy1024 <[email protected]>
Signed-off-by: Song Gao <[email protected]>
Co-authored-by: Song Gao <[email protected]>
Signed-off-by: Song Gao [email protected]
What problem does this PR solve?
If the region have no leader during balance-region, it will pause PD panic and restart over and over.
What is changed and how it works?
Check region leader before balance region. If it has no leader, the balance for this region would be skipped.
Check List
Tests
Related changes
Release note
balance-region
enabled.