<div id="yui_3_2_0_26_133654979217348" style="font-family:arial,helvetica,sans-serif;font-size:13px"><span id="yui_3_2_0_26_133654979217392">Hi,</span></div><div id="yui_3_2_0_26_133654979217348" style="font-family:arial,helvetica,sans-serif;font-size:13px">

<br></div><div id="yui_3_2_0_26_133654979217348" style="font-family:arial,helvetica,sans-serif;font-size:13px"><span id="yui_3_2_0_26_1336549792173118">The code you have sent is same in </span><span id="yui_3_2_0_26_1336549792173105" style="font-family:'times new roman','new york',times,serif;font-size:16px">child.c. </span></div>

<div id="yui_3_2_0_26_133654979217348" style="font-family:arial,helvetica,sans-serif;font-size:13px"><span id="yui_3_2_0_26_1336549792173108" style="font-family:'times new roman','new york',times,serif;font-size:16px"><br>

</span></div><div id="yui_3_2_0_26_133654979217348" style="font-family:arial,helvetica,sans-serif;font-size:13px"><span id="yui_3_2_0_26_1336549792173113" style="font-family:'times new roman','new york',times,serif;font-size:16px">I have attached the log file. Please check</span></div>

<div id="yui_3_2_0_26_133654979217354" style="font-family:arial,helvetica,sans-serif;font-size:13px"> </div><p id="yui_3_2_0_26_133654979217357" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><font face="arial, helvetica, sans-serif">--</font><font face="'comic sans ms', sans-serif">Aravinth</font>
</p><br><br><div class="gmail_quote">On Tue, May 8, 2012 at 6:20 AM, 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">

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>
<div class="im">--<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>
</div>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);            <-- 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 > 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>
<div class="im">                }<br>
        }<br>
<br>
        pool_debug("select_load_balancing_node: selected backend id is %d", selected_slot);<br>
</div>        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 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 Solaris<br>
<div class="HOEnZb"><div class="h5">><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", 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 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 always<br>
>> select the same node.<br>
>> No effect in changing the backend weight. Only when I set backend 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 ( centos<br>
>> ,RHEL, ubunt etc) does the load balancing perfectly.<br>
>><br>
>> Also tries various postgres versions and pgpool version with same 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>
</div></div></blockquote></div><br>