BUG/MINOR: hash-balance-factor isn't effective in certain circumstances
authorAndrew Rodland <andrew@cleverdomain.org>
Wed, 26 Apr 2017 06:57:03 +0000 (02:57 -0400)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Apr 2017 13:45:27 +0000 (15:45 +0200)
commit18330ab17fb36a3eb8292c8c128751e0d230ec27
treed8c5ddefe6f8197830c848371ad9f6b0f4a7c1ff
parente068b60605ad5bdf7ec3bde016b4f681171f5443
BUG/MINOR: hash-balance-factor isn't effective in certain circumstances

in chash_get_server_hash, we find the nearest server entries both
before and after the request hash. If the next and prev entries both
point to the same server, the function would exit early and return that
server, to save work.

Before hash-balance-factor this was a valid optimization -- one of nsrv
and psrv would definitely be chosen, so if they are the same there's no
need to choose between them. But with hash-balance-factor it's possible
that adding another request to that server would overload it
(chash_server_is_eligible returns false) and we go further around the
ring. So it's not valid to return before checking for that.

This commit simply removes the early return, as it provides a minimal
savings even when it's correct.
src/lb_chash.c