throttler: Fixed a bug in the rate increase.

The code did not correctly set the new rate to the middle of [previous rate,lowest bad].
This commit is contained in:
Michael Berlin 2016-08-21 22:58:14 -07:00
Родитель 9c1efa0daf
Коммит cff9ca0c9d
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -327,7 +327,7 @@ func (m *MaxReplicationLagModule) increaseRate(now time.Time, lagRecordNow repli
if lowestBad != 0 {
if rate > lowestBad {
// New rate will be the middle value of [previous rate, lowest bad rate].
rate -= (lowestBad - previousRate) / 2
rate = previousRate + (lowestBad-previousRate)/2
increaseReason += fmt.Sprintf(" (but limited to the middle value in the range [previous rate, lowest bad rate]: [%.0f, %.0f]", previousRate, lowestBad)
}
}
@ -335,7 +335,7 @@ func (m *MaxReplicationLagModule) increaseRate(now time.Time, lagRecordNow repli
increase := (rate - previousRate) / previousRate
m.updateNextAllowedIncrease(now, increase, lagRecordNow.Key)
reason := fmt.Sprintf("periodic increase of the %v from %d to %d (by %.1f%%) based on %v to find out the maximum - next allowed increase in %.0f seconds",
previousRateSource, oldRate, int64(rate), increase*100, increaseReason, m.nextAllowedIncrease.Sub(now).Seconds())
previousRateSource, int64(previousRate), int64(rate), increase*100, increaseReason, m.nextAllowedIncrease.Sub(now).Seconds())
m.updateRate(stateIncreaseRate, int64(rate), reason, now, lagRecordNow)
}