[Pgpool-hackers] backend weighting calculation is wrong

Jeff Davis pgpool at j-davis.com
Tue Sep 26 16:24:34 UTC 2006


On Tue, 2006-09-26 at 10:53 +0900, Yoshiyuki Asaba wrote:
> > Thank you, it works great.
> > 
> > So that I can learn how to write code that fits with your code, can you
> > tell me how I could have improved my patch? I don't understand why you
> > introduced the variables "j" and "alive_backends". Does my patch fail in
> > some scenario?
> 
> I am worried that any backend is not selected by round-off error when
> "r" is near RAND_MAX. So I introduced the variables to select a last
> backend in this case. But it is very rare case...
> 

Are you sure? I examined the code several times and it appears to me to
handle that situation correctly. 

In my second loop, total_weight starts at zero so as long as
(1) There is at least one valid backend; and
(2) r > 0

my code should always set selected_slot.

I think I may have made a bad assumption on #2, but that could easily be
corrected by using ">=" rather than ">" in my code.

Regards,
	Jeff Davis



More information about the Pgpool-hackers mailing list