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
Conversation
// Region1: L F F F | ||
s.tc.updateLeaderCount(1, 10) | ||
s.tc.updateLeaderCount(1, 16) |
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.
Why change to 16?
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.
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
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.
LGTM
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.
LGTM.
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.