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

fix score when region size is zero #899

Merged
merged 4 commits into from Jan 4, 2018
Merged

Conversation

Connor1996
Copy link
Member

when region size is zero, the score will be zero accordingly. When scheduler move this kind of regions, the score of store isn't affected, leading to maldistribution of region count for stores.

// Region1: L F F F
s.tc.updateLeaderCount(1, 10)
s.tc.updateLeaderCount(1, 16)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change to 16?

Copy link
Member Author

Choose a reason for hiding this comment

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

note that: shouldBalance() uses math.Min(sourceSizeDiff, targetSizeDiff) >= float64(region.ApproximateSize)*tolerantRatio to decide whether to balance.

Before when size is zero, score is zero. for this case,
// Stores: 1 2 3 4
// Score: 100 0 0 0
avgScore is 25, and sizediff satisfy the formula above just enough

After when size is zero, score is 1, so for this case
// Stores: 1 2 3 4
// Score: 100 1 1 1
avgScore is 25.75, and sizediff doesn't satisfy the formula above

so enlarge the leader count

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

Copy link
Contributor

@disksing disksing left a comment

Choose a reason for hiding this comment

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

LGTM.

@disksing disksing merged commit 102cfe8 into tikv:master Jan 4, 2018
@Connor1996 Connor1996 deleted the score branch January 4, 2018 10:31
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.

None yet

3 participants