[Pgpool-hackers] backend weighting calculation is wrong

Yoshiyuki Asaba y-asaba at sraoss.co.jp
Tue Sep 26 01:53:30 UTC 2006


From: Jeff Davis <pgpool at j-davis.com>
Subject: Re: [Pgpool-hackers] backend weighting calculation is wrong
Date: Mon, 25 Sep 2006 15:37:14 -0700

> On Mon, 2006-09-25 at 14:24 +0900, Yoshiyuki Asaba wrote:
> > From: Jeff Davis <pgpool at j-davis.com>
> > Subject: [Pgpool-hackers] backend weighting calculation is wrong
> > Date: Wed, 13 Sep 2006 16:57:26 -0700
> > 
> > > 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 confirmed the problem. It's a bug.
> > 
> > 
> > > I have attached a short patch. I am not an expert in random number
> > > handling, so someone else should review my code.
> > 
> > I review and modify your patch. Could you test the attached patch?
> > 
> 
> 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...

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


More information about the Pgpool-hackers mailing list