From: Andrew Rodland Date: Wed, 26 Apr 2017 06:57:03 +0000 (-0400) Subject: BUG/MINOR: hash-balance-factor isn't effective in certain circumstances X-Git-Tag: v1.8-dev2~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18330ab17fb36a3eb8292c8c128751e0d230ec27;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/lb_chash.c b/src/lb_chash.c index 84a2ef36e4..2394baa120 100644 --- a/src/lb_chash.c +++ b/src/lb_chash.c @@ -306,10 +306,8 @@ struct server *chash_get_server_hash(struct proxy *p, unsigned int hash) nsrv = eb32_entry(next, struct tree_occ, node)->server; psrv = eb32_entry(prev, struct tree_occ, node)->server; - if (nsrv == psrv) - return nsrv; - /* OK we're located between two distinct servers, let's + /* OK we're located between two servers, let's * compare distances between hash and the two servers * and select the closest server. */