[Pgpool-hackers] backend weighting calculation is wrong

Yoshiyuki Asaba y-asaba at sraoss.co.jp
Wed Sep 27 02:01:36 UTC 2006


From: Jeff Davis <pgpool at j-davis.com>
Subject: Re: [Pgpool-hackers] backend weighting calculation is wrong
Date: Tue, 26 Sep 2006 09:24:34 -0700

> 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.

Sorry, I guess wrong. Your patch is correct.


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

OK. Merge this into your patch. 
Thanks.

--
Yoshiyuki Asaba
y-asaba at sraoss.co.jp


More information about the Pgpool-hackers mailing list