<div dir="ltr">Ok, looks like the connections I see on pgpool2 are just healthchecks and standard db SELECT calls:<div>







<p class=""><span class="">SELECT 1;</span></p><div><p class=""><span class="">SELECT </span>class.relname, blocking_activity.client_addr, blocking_activity.query FROM  pg_catalog.pg_locks blocked JOIN pg_catalog.pg_stat_activity a ON a.pid=blocked.pid JOIN pg_catalog.pg_locks locks ON locks.locktype = blocked.locktype AND locks.DATABASE IS NOT DISTINCT FROM blocked.DATABASE AND locks.relation IS NOT DISTINCT FROM blocked.relation AND locks.page IS NOT DISTINCT FROM blocked.page AND locks.tuple IS NOT DISTINCT FROM blocked.tuple AND locks.virtualxid IS NOT DISTINCT FROM blocked.virtualxid AND locks.transactionid IS NOT DISTINCT FROM blocked.transactionid AND locks.classid IS NOT DISTINCT FROM blocked.classid AND locks.objid IS NOT DISTINCT FROM blocked.objid AND locks.objsubid IS NOT DISTINCT FROM blocked.objsubid AND locks.pid != blocked.pid JOIN pg_catalog.pg_stat_activity blocking_activity ON blocking_activity.pid=locks.pid JOIN pg_catalog.pg_class class ON class.oid=locks.relation WHERE NOT blocked.GRANTED;</p><p class="">I think we can consider this solved. Thank you, guys, for helping with this.</p><p class="">Regards,</p><p class="">Vlad</p></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 22, 2016 at 3:41 PM, Tatsuo Ishii <span dir="ltr">&lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; Hello,<br>
&gt;<br>
&gt; I attach node only when I start the failover node (PostgreSQL) after<br>
&gt; primary is up and running. E.g. I start PostgreSQL on pgpool1, then I start<br>
&gt; popool-II and it detects the backend.<br>
<br>
</span>Probably at this point a fail over happens because PostgreSQL pgpool2<br>
is not running. So far so good.<br>
<span class=""><br>
&gt; Then, when I start pgpool2, I need to<br>
&gt; manually attach it, so pgpool-II would know that the backend is online,<br>
&gt; right?<br>
<br>
</span>Correct.<br>
<span class=""><br>
&gt; Now nodes status. At this moment I see following nodes status:<br>
&gt; node_id  hostname   port   status   lb_weight  role       select_cnt<br>
&gt; 0        pgpool1    5432      2     0.500000   primary    66133198<br>
&gt; 1        pgpool2    5432      2     0.500000   standby    0<br>
<br>
</span>I don&#39;t know which node you executed &quot;show pool_nodes&quot; but as long as<br>
the result of the command are same, it is ok.<br>
<br>
So you sometimes see write queries are sent to PostgreSQL on pgpool2?<br>
<span class=""><br>
&gt; I have a sneaky feeling that lb_weight has something to do about what is<br>
&gt; going on. However, if you take a look at the pgpool.conf attached to the<br>
&gt; initial message, you&#39;ll find the backends configured like this:<br>
&gt; backend_hostname0 = &#39;pgpool1&#39;<br>
&gt; backend_port0 = 5432<br>
&gt; backend_weight0 = 1<br>
&gt; backend_data_directory0 = &#39;/var/lib/pgsql/9.4/data&#39;<br>
&gt; backend_flag0 = &#39;ALLOW_TO_FAILOVER&#39;<br>
&gt;<br>
&gt; backend_hostname1 = &#39;pgpool2&#39;<br>
&gt; backend_port1 = 5432<br>
&gt; backend_weight1 = 1<br>
&gt; backend_data_directory1 = &#39;/var/lib/pgsql/9.4/data&#39;<br>
&gt; backend_flag1 = &#39;ALLOW_TO_FAILOVER&#39;<br>
&gt;<br>
&gt; In particular, backend_weight is set to 1 on both nodes.<br>
<br>
</span>Don&#39;t worry. The load balance weight is always &quot;normalized&quot; so that<br>
the tatal weight is 1.0.<br>
<span class=""><br>
&gt; Also, as far as I<br>
&gt; understand, this setting should not matter when load_balance_mode=off.<br>
<br>
</span>Correct.<br>
<div class="HOEnZb"><div class="h5"><br>
&gt; Regards,<br>
&gt; Vlad<br>
&gt;<br>
&gt;<br>
&gt; On Sat, Aug 20, 2016 at 4:37 PM, Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; &gt; Hi Lucas,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I checked the log and found no failover entries. Here&#39;s how that<br>
&gt;&gt; happens. I<br>
&gt;&gt; &gt; start two postgres backends (master-slave streaming replication) and<br>
&gt;&gt; &gt; pgpool-II instance. Then I attach both of the nodes and initially all the<br>
&gt;&gt; &gt; clients get connected to master only.<br>
&gt;&gt;<br>
&gt;&gt; Why do you need attach the backends? Pgpool-II automatically attach<br>
&gt;&gt; all backends valid in pgpool.conf.<br>
&gt;&gt;<br>
&gt;&gt; &gt; I see that with ps ax | grep<br>
&gt;&gt; &gt; postgres. After some time new clients start getting connected to the hot<br>
&gt;&gt; &gt; standby node while older clients are still connected to master. Again, I<br>
&gt;&gt; &gt; see that with ps ax | grep postgres. In that case both master and hot<br>
&gt;&gt; &gt; standby have pgpool-II connected. That&#39;s what concerns me the most. If<br>
&gt;&gt; &gt; there was a failover event, master would&#39;ve been detached and there would<br>
&gt;&gt; &gt; be no pgpool-II connections there.<br>
&gt;&gt;<br>
&gt;&gt; Can you connect to pgool using psql then issue &quot;show pool_nodes&quot; when<br>
&gt;&gt; pgpool starts to behaves like this? This should show which is the<br>
&gt;&gt; primary node (role) and which node should be the node the query routes<br>
&gt;&gt; to (load_balance_node).<br>
&gt;&gt;<br>
&gt;&gt; Best regards,<br>
&gt;&gt; --<br>
&gt;&gt; Tatsuo Ishii<br>
&gt;&gt; SRA OSS, Inc. Japan<br>
&gt;&gt; English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_<wbr>en.php</a><br>
&gt;&gt; Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.<wbr>jp</a><br>
&gt;&gt;<br>
&gt;&gt; &gt; Vlad<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Sat, Aug 20, 2016 at 1:25 AM, Lucas Luengas &lt;<a href="mailto:lucasluengas@gmail.com">lucasluengas@gmail.com</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Hello.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Have you checked pgpool log file?  Maybe a failover happened?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Fri, Aug 19, 2016 at 10:48 PM, Vlad Novikov &lt;<a href="mailto:xou.slackware@gmail.com">xou.slackware@gmail.com</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Hello,<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; I&#39;m have setup pgpool-II with 2 backends in streaming mode (see<br>
&gt;&gt; &gt;&gt;&gt; configuration file attached). In particular, I have load_balance_mode<br>
&gt;&gt; = off<br>
&gt;&gt; &gt;&gt;&gt; to make sure that in this pool all connections will be established to<br>
&gt;&gt; &gt;&gt;&gt; streaming master only. However, over some time I see pgpool-II<br>
&gt;&gt; establishing<br>
&gt;&gt; &gt;&gt;&gt; connections to hot standby server. As a result client applications<br>
&gt;&gt; start<br>
&gt;&gt; &gt;&gt;&gt; failing as they cannot write to the database they&#39;re connected to. So<br>
&gt;&gt; far<br>
&gt;&gt; &gt;&gt;&gt; the only solution for me is to keep the hot standby detached (which is<br>
&gt;&gt; not<br>
&gt;&gt; &gt;&gt;&gt; a good idea in terms of automated failover).<br>
&gt;&gt; &gt;&gt;&gt; Pgpool-II starts behaving like this at about 100 clients connected.<br>
&gt;&gt; &gt;&gt;&gt; PostgreSQL max_connections is set to 900 and with hot standby detached<br>
&gt;&gt; &gt;&gt;&gt; there are no connection issues reported (all clients can connect to the<br>
&gt;&gt; &gt;&gt;&gt; backend with no issues).<br>
&gt;&gt; &gt;&gt;&gt; I use pgpool-II and PostgreSQL provided by PostgreSQL official<br>
&gt;&gt; repository.<br>
&gt;&gt; &gt;&gt;&gt; PostgreSQL 9.4.9<br>
&gt;&gt; &gt;&gt;&gt; pgpool-II 3.5.3<br>
&gt;&gt; &gt;&gt;&gt; OS: CentOS 7.2<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Is there anything I need to change in the configuration file to make<br>
&gt;&gt; all<br>
&gt;&gt; &gt;&gt;&gt; clients connect to master only when both backends are attached? From<br>
&gt;&gt; what I<br>
&gt;&gt; &gt;&gt;&gt; understand that is expected with load_balance_mode = off.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Regards,<br>
&gt;&gt; &gt;&gt;&gt; Vlad<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; &gt;&gt;&gt; pgpool-general mailing list<br>
&gt;&gt; &gt;&gt;&gt; <a href="mailto:pgpool-general@pgpool.net">pgpool-general@pgpool.net</a><br>
&gt;&gt; &gt;&gt;&gt; <a href="http://www.pgpool.net/mailman/listinfo/pgpool-general" rel="noreferrer" target="_blank">http://www.pgpool.net/mailman/<wbr>listinfo/pgpool-general</a><br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt;<br>
</div></div></blockquote></div><br></div>