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

*: store balance weight. #713

Merged
merged 9 commits into from
Sep 1, 2017
Merged

*: store balance weight. #713

merged 9 commits into from
Sep 1, 2017

Conversation

disksing
Copy link
Contributor

No description provided.

}

func newStoreInfo(store *metapb.Store) *StoreInfo {
return &StoreInfo{
Store: store,
Store: store,
LeaderWeight: 1.0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about set default value as 100?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the weight is unset, the score will be the same as old score, because newScore = oldScore / weight.

func (s *testBalanceLeaderSchedulerSuite) TestLeaderWeight(c *C) {
// Stores: 1 2 3 4
// Leaders: 10 10 10 10
// Weight: 0.5 0.5 1 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/0.5 0.5/0.5 0.9/

@@ -169,8 +180,20 @@ func (kv *kv) loadStores(stores *storesInfo, rangeLimit int64) error {
return errors.Trace(err)
}

storeInfo := newStoreInfo(store)
leaderWeight, err := kv.loadFloatWithDefaultValue(kv.storeLeaderWeightPath(storeInfo.GetId()), 1.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting a loadStoreWeight and test them.

return errors.Trace(errStoreNotFound(storeID))
}

if err := c.s.kv.saveStoreWeight(storeID, leader, region); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving this inside clusterInfo.putStore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clusterInfo.putStore has other callers, SetStoreLabel, DeleteStore, etc. They won't change the weight, so I think put saveStoreWeight outside is more suitable.

@huachaohuang
Copy link
Contributor

Will this affect BalanceHotRegionScheduler?
If one of the stores has a larger weight, it may contain more hot regions than others, will it fight with the BalanceLeaderScheduler and BalanceRegionScheduler?

@disksing
Copy link
Contributor Author

If BalanceLeaderScheduler and BalanceRegionScheduler try to balance a hot region, it will conflict with BalanceHotRegionScheduler. It is not directly related to store weight, they have conflicts with or without store weight. We resolve it by setting up higher priorities for operators created by BalanceHotRegionScheduler.

@huachaohuang
Copy link
Contributor

Maybe BalanceHotRegionScheduler need to consider the store weight too?
Otherwise, BalanceHotRegionScheduler may keep trying to transfer leaders from a store with a larger weight to a store with a smaller weight, while BalanceLeaderScheduler may keep trying to transfer leaders backward, will that happen?

@disksing
Copy link
Contributor Author

There are too many hacks in hotRegionScheduler. Seems more easy to skip hot regions in BalanceLeaderScheduler and BalanceRegionScheduler. Any second thought?

@huachaohuang
Copy link
Contributor

I still think that BalanceHotRegionScheduler should consider store weight too, maybe we can find a more general way to make them work well together later.
LGTM

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. maybe we can add hot region weight later.

@disksing disksing merged commit fd35f50 into master Sep 1, 2017
@disksing disksing deleted the disksing/store-weight branch September 1, 2017 11:17
@keroro520
Copy link

Hi. Could anyone explain the actual meaning of Weight and Score, and the relation between them ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants