Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#8160
Browse files Browse the repository at this point in the history
close tikv#8159

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
nolouch authored and ti-chi-bot committed May 20, 2024
1 parent 286add2 commit e1e1a5e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions client/resource_group/controller/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ func (lim *Limiter) AvailableTokens(now time.Time) float64 {
return tokens
}

const reserveWarnLogInterval = 10 * time.Millisecond

// reserveN is a helper method for Reserve.
// maxFutureReserve specifies the maximum reservation wait duration allowed.
// reserveN returns Reservation, not *Reservation.
Expand Down Expand Up @@ -374,6 +376,7 @@ func (lim *Limiter) reserveN(now time.Time, n float64, maxFutureReserve time.Dur
lim.tokens = tokens
lim.maybeNotify()
} else {
<<<<<<< HEAD
log.Warn("[resource group controller] cannot reserve enough tokens",
zap.Duration("need-wait-duration", waitDuration),
zap.Duration("max-wait-duration", maxFutureReserve),
Expand All @@ -382,6 +385,21 @@ func (lim *Limiter) reserveN(now time.Time, n float64, maxFutureReserve time.Dur
zap.Float64("request-tokens", n),
zap.Int64("burst", lim.burst),
zap.Int("remaining-notify-times", lim.remainingNotifyTimes))
=======
// print log if the limiter cannot reserve for a while.
if time.Since(lim.last) > reserveWarnLogInterval {
log.Warn("[resource group controller] cannot reserve enough tokens",
zap.Duration("need-wait-duration", waitDuration),
zap.Duration("max-wait-duration", maxFutureReserve),
zap.Float64("current-ltb-tokens", lim.tokens),
zap.Float64("current-ltb-rate", float64(lim.limit)),
zap.Float64("request-tokens", n),
zap.Float64("notify-threshold", lim.notifyThreshold),
zap.Bool("is-low-process", lim.isLowProcess),
zap.Int64("burst", lim.burst),
zap.Int("remaining-notify-times", lim.remainingNotifyTimes))
}
>>>>>>> a674e668f (controller: Reduce the frequency of printing logs (#8160))
lim.last = last
if lim.limit == 0 {
lim.notify()
Expand Down

0 comments on commit e1e1a5e

Please sign in to comment.