Sorry . I missed it.<div><br></div><div>Here is the log file.</div><div><br clear="all"><font style="color:rgb(0,0,0);font-family:arial narrow,sans-serif" size="2"><font style="color:rgb(0,0,0)"><span style="font-family:comic sans ms,sans-serif">--Aravinth</span></font></font> <br>


<br><br><div class="gmail_quote">On Wed, May 9, 2012 at 2:07 PM, Tatsuo Ishii <span dir="ltr"><<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">> The code you have sent is same in child.c.<br>
<br>
</div>No.<br>
<div class="im"><br>
        pool_log("r: %f total_weight: %f", r, total_weight);<br>
<br>
</div>You need to add the line above to get usefull information.<br>
<div class="HOEnZb"><div class="h5">--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
<br>
<br>
> I have attached the log file. Please check<br>
><br>
><br>
> --Aravinth<br>
><br>
><br>
> On Tue, May 8, 2012 at 6:20 AM, Tatsuo Ishii <<a href="mailto:ishii@postgresql.org">ishii@postgresql.org</a>> wrote:<br>
><br>
>> I suspect there's some portablity issue with load balance code. The<br>
>> actual source code is in select_load_balancing_nodechild.c).<br>
>> Please modify source code and connect to pgpool by using psql.<br>
>> Please send the log output.<br>
>> --<br>
>> Tatsuo Ishii<br>
>> SRA OSS, Inc. Japan<br>
>> English: <a href="http://www.sraoss.co.jp/index_en.php" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
>> Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
>><br>
>> int select_load_balancing_node(void)<br>
>> {<br>
>>        int selected_slot;<br>
>>        double total_weight,r;<br>
>>        int i;<br>
>><br>
>>        /* choose a backend in random manner with weight */<br>
>>        selected_slot = MASTER_NODE_ID;<br>
>>        total_weight = 0.0;<br>
>><br>
>>        for (i=0;i<NUM_BACKENDS;i++)<br>
>>        {<br>
>>                if (VALID_BACKEND(i))<br>
>>                {<br>
>>                        total_weight += BACKEND_INFO(i).backend_weight;<br>
>>                }<br>
>>        }<br>
>>        r = (((double)random())/RAND_MAX) * total_weight;<br>
>>        pool_log("r: %f total_weight: %f", r, total_weight);            <--<br>
>> add this<br>
>><br>
>>        total_weight = 0.0;<br>
>>        for (i=0;i<NUM_BACKENDS;i++)<br>
>>        {<br>
>>                if (VALID_BACKEND(i) && BACKEND_INFO(i).backend_weight ><br>
>> 0.0)<br>
>>                {<br>
>>                        if(r >= total_weight)<br>
>>                                selected_slot = i;<br>
>>                        else<br>
>>                                break;<br>
>>                        total_weight += BACKEND_INFO(i).backend_weight;<br>
>>                 }<br>
>>        }<br>
>><br>
>>        pool_debug("select_load_balancing_node: selected backend id is %d",<br>
>> selected_slot);<br>
>>         return selected_slot;<br>
>> }<br>
>><br>
>><br>
>> > Hi Tatsuo, Thanks for the reply.<br>
>> ><br>
>> > The normalized weights are 0.5 for both nodes and the selected node is<br>
>> always the same node. I hope then it's srandom().<br>
>> ><br>
>> ><br>
>> > Any idea to solve this srandom issue<br>
>> ><br>
>> ><br>
>> > Thanks and Regards,<br>
>> > Aravinth<br>
>> ><br>
>> ><br>
>> > ________________________________<br>
>> >  From: Tatsuo Ishii <<a href="mailto:ishii@postgresql.org">ishii@postgresql.org</a>><br>
>> > To: <a href="mailto:aravinth@mafiree.com">aravinth@mafiree.com</a><br>
>> > Cc: <a href="mailto:pgpool-general@pgpool.net">pgpool-general@pgpool.net</a><br>
>> > Sent: Tuesday, May 1, 2012 4:41 AM<br>
>> > Subject: Re: [pgpool-general: 396] strange load balancing issue in<br>
>> Solaris<br>
>> ><br>
>> > First of all please check "normalized" weights are as you expected.<br>
>> > Run "show pool_status;" and see "backend_weight0", "backend_weight1"<br>
>> > section. You see a floating point numbers, which are the normalized<br>
>> > weight between 0.0 and 1.0. If you see both are 0.5, primary and<br>
>> > standby are given same weight.<br>
>> ><br>
>> > If they are ok, I suspect srandom() function behavior is different<br>
>> > from other platforms. Pgpool-II chooses the load balance node by using<br>
>> > srandom(). select_load_balancing_node() is the function which is<br>
>> > responsible for selecting the load balance node. If you run pgpool-II<br>
>> > with -d (debug) option, you will see following in the log:<br>
>> ><br>
>> >     pool_debug("select_load_balancing_node: selected backend id is %d",<br>
>> selected_slot);<br>
>> ><br>
>> > If backend_weight in show pool_status are fine but the line above<br>
>> > always shows same number, it is the sign that we have problem with<br>
>> > srandom().<br>
>> > --<br>
>> > Tatsuo Ishii<br>
>> > SRA OSS, Inc. Japan<br>
>> > English: <a href="http://www.sraoss.co.jp/index_en.php" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
>> > Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
>> ><br>
>> >> Hi All,<br>
>> >><br>
>> >> I am facing a strange issue in load balancing with replication mode set<br>
>> to<br>
>> >> true in Solaris. Load balancing algorithm always select the same node<br>
>> >> whatever may be the backend weight<br>
>> >><br>
>> >> Here is the scenario.<br>
>> >><br>
>> >> I have a pgpool installed installed in 1 server<br>
>> >> 2 postgres nodes in other 2 servers<br>
>> >> replication mode set to true and load balancing set to true<br>
>> >> backend weight of the 2 nodes is 1.<br>
>> >><br>
>> >> When I fire the queries manuall using different connections or using<br>
>> >> pgbench all the queries hit the same node. Load balancing algorithm<br>
>> always<br>
>> >> select the same node.<br>
>> >> No effect in changing the backend weight. Only when I set backend<br>
>> weight to<br>
>> >> 0 hits go to the other server.<br>
>> >><br>
>> >><br>
>> >> I face this issue only in solaris. The same setup in other servers (<br>
>> centos<br>
>> >> ,RHEL, ubunt etc) does the load balancing perfectly.<br>
>> >><br>
>> >> Also tries various postgres versions and pgpool version with same<br>
>> result.<br>
>> >> But every version runs fine in other servers.<br>
>> >><br>
>> >> Has anyone faced this issue?<br>
>> >><br>
>> >> Any information would highly helpful.<br>
>> >><br>
>> >> Regards,<br>
>> >> Aravinth<br>
>> _______________________________________________<br>
>> pgpool-general mailing list<br>
>> <a href="mailto:pgpool-general@pgpool.net">pgpool-general@pgpool.net</a><br>
>> <a href="http://www.pgpool.net/mailman/listinfo/pgpool-general" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-general</a><br>
>><br>
</div></div></blockquote></div><br></div>