]> git.ipfire.org Git - thirdparty/haproxy.git/commit
[BUG] consistent hash: balance on all servers, not only 2 !
authorWilly Tarreau <w@1wt.eu>
Tue, 25 May 2010 21:03:02 +0000 (23:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 4 Jun 2010 12:36:39 +0000 (14:36 +0200)
commitdd701651fe1a0e28c3634d6809485047dea3c2bb
tree409a885ec50178773d046682e6fa652d2d30c37e
parent23968d898a68b21b49a83ffc74ff18bfd9323bb5
[BUG] consistent hash: balance on all servers, not only 2 !

It was once reported at least by Dirk Taggesell that the consistent
hash had a very poor distribution, making use of only two servers.
Jeff Persch analysed the code and found the root cause. Consistent
hash makes use of the server IDs, which are completed after the chash
array initialization. This implies that each server which does not
have an explicit "id" parameter will be merged at the same place in
the chash tree and that in the end, only the first or last servers
may be used.

The now obvious fix (thanks to Jeff) is to assign the missing IDs
earlier. However, it should be clearly understood that changing a
hash algorithm on live systems will rebalance the whole system.
Anyway, the only affected users will be the ones for which the
system is quite unbalanced already. The ones who fix their IDs are
not affected at all.

Kudos to Jeff for spotting that bug which got merged 3 days after
the consistent hashing !
src/cfgparse.c