Tatsuo,<br><br>Did you restart iptables after adding rule?<br><br>Regards,<br>Stevo.<br><br><div class="gmail_quote">On Wed, Jan 11, 2012 at 11:12 AM, Stevo Slavić <span dir="ltr">&lt;<a href="mailto:sslavic@gmail.com">sslavic@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looking into this to verify if these are all necessary changes to have port unreachable message silently rejected (suspecting some kernel parameter tuning is needed).<br>
<br>Just to clarify it&#39;s not a problem that host is being detected by pgpool to be down, but the timing when that happens. On environment where issue is reproduced pgpool as part of health check attempt tries to connect to backend and hangs for tcp timeout instead of being interrupted by timeout alarm. Can you verify/confirm please the health check retry timings are not delayed?<br>

<br>Regards,<br>Stevo.<div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On Wed, Jan 11, 2012 at 10:50 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">
Ok, I did:<br>
<div><br>
# iptables -A FORWARD -j REJECT --reject-with icmp-port-unreachable<br>
<br>
</div>on the host where pgpoo is running. And pull network cable from<br>
<div>backend0 host network interface. Pgpool detected the host being down<br>
</div>as expected...<br>
<div><div>--<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>
&gt; Backend is not destination of this message, pgpool host is, and we don&#39;t<br>
&gt; want it to ever get it. With command I&#39;ve sent you rule will be created for<br>
&gt; any source and destination.<br>
&gt;<br>
&gt; Regards,<br>
&gt; Stevo.<br>
&gt;<br>
&gt; On Wed, Jan 11, 2012 at 10:38 AM, Tatsuo Ishii &lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; I did following:<br>
&gt;&gt;<br>
&gt;&gt; Do following on the host where pgpool is running on:<br>
&gt;&gt;<br>
&gt;&gt; # iptables -A FORWARD -j REJECT --reject-with icmp-port-unreachable -d<br>
&gt;&gt; 133.137.177.124<br>
&gt;&gt; (133.137.177.124 is the host where backend is running on)<br>
&gt;&gt;<br>
&gt;&gt; Pull network cable from backend0 host network interface. Pgpool<br>
&gt;&gt; detected the host being down as expected. Am I missing something?<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" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
&gt;&gt; Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
&gt;&gt;<br>
&gt;&gt; &gt; Hello Tatsuo,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; With backend0 on one host just configure following rule on other host<br>
&gt;&gt; where<br>
&gt;&gt; &gt; pgpool is:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; iptables -A FORWARD -j REJECT --reject-with icmp-port-unreachable<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; and then have pgpool startup with health checking and retrying<br>
&gt;&gt; configured,<br>
&gt;&gt; &gt; and then pull network cable from backend0 host network interface.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Regards,<br>
&gt;&gt; &gt; Stevo.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Wed, Jan 11, 2012 at 6:27 AM, Tatsuo Ishii &lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; I want to try to test the situation you descrived:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; When system is configured for security reasons not to return<br>
&gt;&gt; &gt;&gt; destination<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; host unreachable messages, even though health_check_timeout is<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; But I don&#39;t know how to do it. I pulled out the network cable and<br>
&gt;&gt; &gt;&gt; pgpool detected it as expected. Also I configured the server which<br>
&gt;&gt; &gt;&gt; PostgreSQL is running on to disable the 5432 port. In this case<br>
&gt;&gt; &gt;&gt; connect(2) returned EHOSTUNREACH (No route to host) so pgpool detected<br>
&gt;&gt; &gt;&gt; the error as expected.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Could you please instruct me?<br>
&gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; Tatsuo Ishii<br>
&gt;&gt; &gt;&gt; SRA OSS, Inc. Japan<br>
&gt;&gt; &gt;&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;&gt; &gt;&gt; Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; Hello Tatsuo,<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Thank you for replying!<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; I&#39;m not sure what exactly is blocking, just by pgpool code analysis I<br>
&gt;&gt; &gt;&gt; &gt; suspect it is the part where a connection is made to the db and it<br>
&gt;&gt; &gt;&gt; doesn&#39;t<br>
&gt;&gt; &gt;&gt; &gt; seem to get interrupted by alarm. Tested thoroughly health check<br>
&gt;&gt; &gt;&gt; behaviour,<br>
&gt;&gt; &gt;&gt; &gt; it works really well when host/ip is there and just backend/postgres<br>
&gt;&gt; is<br>
&gt;&gt; &gt;&gt; &gt; down, but not when backend host/ip is down. I could see in log that<br>
&gt;&gt; &gt;&gt; initial<br>
&gt;&gt; &gt;&gt; &gt; health check and each retry got delayed when host/ip is not reachable,<br>
&gt;&gt; &gt;&gt; &gt; while when just backend is not listening (is down) on the reachable<br>
&gt;&gt; &gt;&gt; host/ip<br>
&gt;&gt; &gt;&gt; &gt; then initial health check and all retries are exact to the settings in<br>
&gt;&gt; &gt;&gt; &gt; pgpool.conf.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; PGCONNECT_TIMEOUT is listed as one of the libpq environment variables<br>
&gt;&gt; in<br>
&gt;&gt; &gt;&gt; &gt; the docs (see<br>
&gt;&gt; &gt;&gt; <a href="http://www.postgresql.org/docs/9.1/static/libpq-envars.html" target="_blank">http://www.postgresql.org/docs/9.1/static/libpq-envars.html</a> )<br>
&gt;&gt; &gt;&gt; &gt; There is equivalent parameter in libpq PGconnectdbParams ( see<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; <a href="http://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-CONNECT-CONNECT-TIMEOUT" target="_blank">http://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-CONNECT-CONNECT-TIMEOUT</a><br>


&gt;&gt; &gt;&gt; )<br>
&gt;&gt; &gt;&gt; &gt; At the beginning of that same page there are some important infos on<br>
&gt;&gt; &gt;&gt; using<br>
&gt;&gt; &gt;&gt; &gt; these functions.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; psql respects PGCONNECT_TIMEOUT.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Regards,<br>
&gt;&gt; &gt;&gt; &gt; Stevo.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; On Wed, Jan 11, 2012 at 12:13 AM, Tatsuo Ishii &lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt;<br>
&gt;&gt; &gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; Hello pgpool community,<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; When system is configured for security reasons not to return<br>
&gt;&gt; &gt;&gt; destination<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; host unreachable messages, even though health_check_timeout is<br>
&gt;&gt; &gt;&gt; &gt;&gt; configured,<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; socket call will block and alarm will not get raised until TCP<br>
&gt;&gt; timeout<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; occurs.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Interesting. So are you saying that read(2) cannot be interrupted by<br>
&gt;&gt; &gt;&gt; &gt;&gt; alarm signal if the system is configured not to return destination<br>
&gt;&gt; &gt;&gt; &gt;&gt; host unreachable message? Could you please guide me where I can get<br>
&gt;&gt; &gt;&gt; &gt;&gt; such that info? (I&#39;m not a network expert).<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; Not a C programmer, found some info that select call could be<br>
&gt;&gt; replace<br>
&gt;&gt; &gt;&gt; &gt;&gt; with<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; select/pselect calls. Maybe it would be best if PGCONNECT_TIMEOUT<br>
&gt;&gt; &gt;&gt; value<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; could be used here for connection timeout. pgpool has libpq as<br>
&gt;&gt; &gt;&gt; &gt;&gt; dependency,<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; why isn&#39;t it using libpq for the healthcheck db connect calls, then<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; PGCONNECT_TIMEOUT would be applied?<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; I don&#39;t think libpq uses select/pselect for establishing connection,<br>
&gt;&gt; &gt;&gt; &gt;&gt; but using libpq instead of homebrew code seems to be an idea. Let me<br>
&gt;&gt; &gt;&gt; &gt;&gt; think about it.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; One question. Are you sure that libpq can deal with the case (not to<br>
&gt;&gt; &gt;&gt; &gt;&gt; return destination host unreachable messages) by using<br>
&gt;&gt; &gt;&gt; &gt;&gt; PGCONNECT_TIMEOUT?<br>
&gt;&gt; &gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; &gt;&gt; Tatsuo Ishii<br>
&gt;&gt; &gt;&gt; &gt;&gt; SRA OSS, Inc. Japan<br>
&gt;&gt; &gt;&gt; &gt;&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;&gt; &gt;&gt; &gt;&gt; Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt;<br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>