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

scheduler: replace move-hot-read-peer with move-hot-read-leader #3657

Merged
merged 4 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions server/schedulers/hot_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,14 +1000,23 @@ func (bs *balanceSolver) buildOperators() ([]*operator.Operator, []Influence) {
srcPeer := bs.cur.region.GetStorePeer(bs.cur.srcStoreID) // checked in getRegionAndSrcPeer
dstPeer := &metapb.Peer{StoreId: bs.cur.dstStoreID, Role: srcPeer.Role}
desc := "move-hot-" + bs.rwTy.String() + "-peer"
lhy1024 marked this conversation as resolved.
Show resolved Hide resolved
op, err = operator.CreateMovePeerOperator(
desc,
bs.cluster,
bs.cur.region,
operator.OpHotRegion,
bs.cur.srcStoreID,
dstPeer)

if bs.rwTy == read && bs.cur.region.GetLeader().StoreId == bs.cur.srcStoreID { // move read leader
op, err = operator.CreateMoveLeaderOperator(
desc,
bs.cluster,
bs.cur.region,
operator.OpHotRegion,
bs.cur.srcStoreID,
dstPeer)
} else {
op, err = operator.CreateMovePeerOperator(
desc,
bs.cluster,
bs.cur.region,
operator.OpHotRegion,
bs.cur.srcStoreID,
dstPeer)
}
counters = append(counters,
hotDirectionCounter.WithLabelValues("move-peer", bs.rwTy.String(), strconv.FormatUint(bs.cur.srcStoreID, 10), "out"),
hotDirectionCounter.WithLabelValues("move-peer", bs.rwTy.String(), strconv.FormatUint(dstPeer.GetStoreId(), 10), "in"))
Expand Down
2 changes: 1 addition & 1 deletion server/schedulers/hot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ func (s *testHotReadRegionSchedulerSuite) TestByteRateOnly(c *C) {
})

// We will move leader peer of region 1 from 1 to 5
testutil.CheckTransferPeerWithLeaderTransfer(c, hb.Schedule(tc)[0], operator.OpHotRegion, 1, 5)
testutil.CheckTransferPeerWithLeaderTransfer(c, hb.Schedule(tc)[0], operator.OpHotRegion|operator.OpLeader, 1, 5)
hb.(*hotScheduler).clearPendingInfluence()

// Should not panic if region not found.
Expand Down