-
Notifications
You must be signed in to change notification settings - Fork 727
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
schedule: improve the leader distribution after region scatter #2659
Conversation
Signed-off-by: nolouch <nolouch@gmail.com>
Signed-off-by: nolouch <nolouch@gmail.com>
server/schedule/region_scatterer.go
Outdated
@@ -153,6 +179,8 @@ func (r *RegionScatterer) scatterRegion(region *core.RegionInfo) *operator.Opera | |||
} | |||
|
|||
scatterWithSameEngine(ordinaryPeers, r.ordinaryEngine) | |||
// FIXME: target leader only consider the ordinary engine. |
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.
What about creating an issue to track this (Ignore me if already).
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 add more comments.
server/schedule/region_scatterer.go
Outdated
@@ -153,6 +179,8 @@ func (r *RegionScatterer) scatterRegion(region *core.RegionInfo) *operator.Opera | |||
} | |||
|
|||
scatterWithSameEngine(ordinaryPeers, r.ordinaryEngine) | |||
// FIXME: target leader only consider the ordinary engine. | |||
targetLeader := r.collectAvailableLeaderStores(targetPeers, r.ordinaryEngine) |
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 the leader store be collected again after collectAvailableLeaderStores
in scatterWithSameEngine
function?
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.
now, only consider the dorinaryEngine.
func (s *selectedLeaderStores) put(id uint64) { | ||
s.mu.Lock() | ||
defer s.mu.Unlock() | ||
s.stores[id] = s.stores[id] + 1 | ||
} |
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.
If the leader is transferred manually, will the old store's count minus 1 and new store's count plus 1?
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.
Yes, you are right. This scheduler assumes that the leader and region will not change significantly after scheduling. Maybe we need to discuss optimization in another issue.
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 we can directly to make a mechanism (syncer or tracker) to record the correct leader count distribution.
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.
In fact, it will be more complicated to do this, such as truncate table
we need to remove the regions from the tracker, and what if recover a table
? The current approach is at least feasible in general, there will be no more operator after cluster in balanced, especially in big cluster.
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.
But the tracker you mentioned is a good idea, and I even want to use it to report why there is this operator produce.
cc @Yisaer
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
Signed-off-by: nolouch <nolouch@gmail.com>
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
/merge |
/run-all-tests |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-4.0 in PR #2684 |
…2659) Signed-off-by: nolouch <nolouch@gmail.com>
#2684) Signed-off-by: nolouch <nolouch@gmail.com>
Signed-off-by: nolouch nolouch@gmail.com
What problem does this PR solve?
Fix #2655
What is changed and how it works?
Check List
Tests
the new result with this PR.
Release note