<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:&#39;times new roman&#39;,&#39;new york&#39;,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:&#39;times new roman&#39;,&#39;new york&#39;,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:&#39;times new roman&#39;,&#39;new york&#39;,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="&#39;comic sans ms&#39;, 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">&lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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