les/vflux/server: fix priority cornercase causing fuzzer timeout (#22650)

* les/vflux/server: fix estimatePriority corner case

* les/vflux/server: simplify inactiveAllowance == 0 case
This commit is contained in:
Felföldi Zsolt
2021-04-16 09:52:33 +02:00
committed by GitHub
parent f8afb681dd
commit 65689e7fce
4 changed files with 19 additions and 17 deletions

View File

@@ -358,11 +358,15 @@ func (n *nodeBalance) estimatePriority(capacity uint64, addBalance int64, future
if bias > 0 {
b = n.reducedBalance(b, now+mclock.AbsTime(future), bias, capacity, 0)
}
// Note: we subtract one from the estimated priority in order to ensure that biased
// estimates are always lower than actual priorities, even if the bias is very small.
pri := n.balanceToPriority(now, b, capacity)
// Ensure that biased estimates are always lower than actual priorities, even if
// the bias is very small.
// This ensures that two nodes will not ping-pong update signals forever if both of
// them have zero estimated priority drop in the projected future.
pri := n.balanceToPriority(now, b, capacity) - 1
current := n.balanceToPriority(now, n.balance, capacity)
if pri >= current {
pri = current - 1
}
if update {
n.addCallback(balanceCallbackUpdate, pri, n.signalPriorityUpdate)
}