Skip to content

Commit

Permalink
ticdc/token-region: don't set metric to 0 since multiple tables share…
Browse files Browse the repository at this point in the history
… it (#3480) (#4291)

* ticdc/token-region: don't set metric to 0 since multiple tables share it

* Update cdc/kv/token_region.go

Co-authored-by: amyangfei <[email protected]>
  • Loading branch information
ti-chi-bot and amyangfei authored Jan 12, 2022
1 parent 0d64b21 commit ef9c22d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cdc/kv/token_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (r *sizedRegionRouter) AddRegion(sri singleRegionInfo) {
r.buffer[id] = append(r.buffer[id], sri)
if _, ok := r.metrics.cachedRegions[id]; !ok {
r.metrics.cachedRegions[id] = cachedRegionSize.WithLabelValues(id, r.metrics.changefeed, r.metrics.capture)
r.metrics.cachedRegions[id].Set(0)
}
r.metrics.cachedRegions[id].Inc()
}
Expand All @@ -119,7 +118,6 @@ func (r *sizedRegionRouter) Acquire(id string) {
r.tokens[id]++
if _, ok := r.metrics.tokens[id]; !ok {
r.metrics.tokens[id] = clientRegionTokenSize.WithLabelValues(id, r.metrics.changefeed, r.metrics.capture)
r.metrics.tokens[id].Set(0)
}
r.metrics.tokens[id].Inc()
}
Expand All @@ -132,7 +130,6 @@ func (r *sizedRegionRouter) Release(id string) {
r.tokens[id]--
if _, ok := r.metrics.tokens[id]; !ok {
r.metrics.tokens[id] = clientRegionTokenSize.WithLabelValues(id, r.metrics.changefeed, r.metrics.capture)
r.metrics.tokens[id].Set(0)
}
r.metrics.tokens[id].Dec()
}
Expand All @@ -143,8 +140,8 @@ func (r *sizedRegionRouter) Run(ctx context.Context) error {
ticker.Stop()
r.lock.Lock()
defer r.lock.Unlock()
for _, m := range r.metrics.cachedRegions {
m.Set(0)
for id, buf := range r.buffer {
r.metrics.cachedRegions[id].Sub(float64(len(buf)))
}
}()
for {
Expand Down

0 comments on commit ef9c22d

Please sign in to comment.