[Pgpool-hackers] backend weighting calculation is wrong

Jeff Davis pgpool at j-davis.com
Wed Sep 13 23:57:26 UTC 2006


I was browsing the code to try to track down my problem with
master_slave_mode and I encountered an algorithm in pool_process_query.c
that randomly selects the backend to which the query will be sent
according to weight.

This algorithm does not look correct. For instance, if you have backends
with weights 1.0 and 2.0, the former will only receive 1/4 of the
queries. I tested this using replication mode with load balancing and
verified the inconsistency.

I have attached a short patch. I am not an expert in random number
handling, so someone else should review my code.

Regards,
	Jeff Davis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pool_process_query.c.patch
Type: text/x-patch
Size: 992 bytes
Desc: not available
Url : http://pgfoundry.org/pipermail/pgpool-hackers/attachments/20060913/d0696cef/attachment.bin 


More information about the Pgpool-hackers mailing list