Skip to content

Commit

Permalink
scheduler: hotspot: add pending influence (#1982)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luffbee authored and sre-bot committed Dec 6, 2019
1 parent 1881cab commit 7811255
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 42 deletions.
11 changes: 11 additions & 0 deletions server/cluster/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ func (c *coordinator) stop() {
type hasHotStatus interface {
GetHotReadStatus() *statistics.StoreHotPeersInfos
GetHotWriteStatus() *statistics.StoreHotPeersInfos
GetWritePendingInfluence() map[uint64]schedulers.Influence
GetReadPendingInfluence() map[uint64]schedulers.Influence
GetStoresScore() map[uint64]float64
}

Expand Down Expand Up @@ -328,6 +330,7 @@ func (c *coordinator) collectHotSpotMetrics() {
}
stores := c.cluster.GetStores()
status := s.Scheduler.(hasHotStatus).GetHotWriteStatus()
pendings := s.Scheduler.(hasHotStatus).GetWritePendingInfluence()
for _, s := range stores {
storeAddress := s.GetAddress()
storeID := s.GetID()
Expand All @@ -349,10 +352,15 @@ func (c *coordinator) collectHotSpotMetrics() {
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "total_written_bytes_as_leader").Set(0)
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "hot_write_region_as_leader").Set(0)
}

infl := pendings[storeID]
// TODO: add to tidb-ansible after merging pending influence into operator influence.
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "write_pending_influence_byte_rate").Set(infl.ByteRate)
}

// Collects hot read region metrics.
status = s.Scheduler.(hasHotStatus).GetHotReadStatus()
pendings = s.Scheduler.(hasHotStatus).GetReadPendingInfluence()
for _, s := range stores {
storeAddress := s.GetAddress()
storeID := s.GetID()
Expand All @@ -365,6 +373,9 @@ func (c *coordinator) collectHotSpotMetrics() {
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "total_read_bytes_as_leader").Set(0)
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "hot_read_region_as_leader").Set(0)
}

infl := pendings[storeID]
hotSpotStatusGauge.WithLabelValues(storeAddress, storeLabel, "read_pending_influence_byte_rate").Set(infl.ByteRate)
}

// Collects score of stores stats metrics.
Expand Down
1 change: 0 additions & 1 deletion server/schedule/operator/create_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ func CreateMoveLeaderOperator(desc string, cluster Cluster, region *core.RegionI
return nil, err
}
st := CreateAddPeerSteps(peer)
st = append(st, TransferLeader{ToStore: peer.StoreId, FromStore: oldStore})
steps = append(st, steps...)
brief := fmt.Sprintf("mv leader: store %v to %v", oldStore, peer.StoreId)
return NewOperator(desc, brief, region.GetID(), region.GetRegionEpoch(), removeKind|kind|OpLeader|OpRegion, steps...), nil
Expand Down
Loading

0 comments on commit 7811255

Please sign in to comment.