<div dir="ltr">One idea to make Pgpool not depend on any status file....<div><br></div><div>Could pgpool2 check/compare the last query&#39;s timestamp saved in the postgresql log file of both nodes?</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 August 2015 at 08:24, 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"><span class="im HOEnZb">No. It measn both replication_mode and master_slave_mode = off.<br>
<br>
</span><div class="HOEnZb"><div class="h5">Best regards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
<br>
&gt; &quot;we need to remove this part except in &quot;raw mode&quot;, in which database<br>
&gt; incosistency problem will not happen.&quot;<br>
&gt;<br>
&gt; Raw mode means &#39;connection_cache=off&#39; ?<br>
&gt; El 06/08/2015 02:30, &quot;Tatsuo Ishii&quot; &lt;<a href="mailto:ishii@postgresql.org">ishii@postgresql.org</a>&gt; escribió:<br>
&gt;<br>
&gt;&gt; It appeared that the behavior (if all backend are down, pgpool_status<br>
&gt;&gt; is ignored) is intentional.<br>
&gt;&gt;<br>
&gt;&gt; From src/main/pgpool_main.c:<br>
&gt;&gt;<br>
&gt;&gt;         /*<br>
&gt;&gt;          * If no one woke up, we regard the status file bogus<br>
&gt;&gt;          */<br>
&gt;&gt;         if (someone_wakeup == false)<br>
&gt;&gt;         {<br>
&gt;&gt;                 for (i=0;i&lt; pool_config-&gt;backend_desc-&gt;num_backends;i++)<br>
&gt;&gt;                 {<br>
&gt;&gt;                         BACKEND_INFO(i).backend_status = CON_CONNECT_WAIT;<br>
&gt;&gt;                 }<br>
&gt;&gt;                 (void)write_status_file();<br>
&gt;&gt;         }<br>
&gt;&gt;<br>
&gt;&gt; Here is the commit log:<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt; commit a97eed16ef8c3a481c0cd0282b9950fb4ee28a89<br>
&gt;&gt; Author: Tatsuo Ishii &lt;ishii at <a href="http://sraoss.co.jp" rel="noreferrer" target="_blank">sraoss.co.jp</a>&gt;<br>
&gt;&gt; Date:   Sat Feb 13 11:23:55 2010 +0000<br>
&gt;&gt;<br>
&gt;&gt;     Fix read_status_file so that if all nodes were marked down status,<br>
&gt;&gt;     it is regarded that this file is bogus. This will prevent &quot;all<br>
&gt;&gt;     node down&quot; syndrome.<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;<br>
&gt;&gt; The decision was made long time ago by me, but now I think this was<br>
&gt;&gt; not correct decision as you pointed out. I think we need to remove<br>
&gt;&gt; this part except in &quot;raw mode&quot;, in which database incosistency problem<br>
&gt;&gt; will not happen.<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_en.php</a><br>
&gt;&gt; Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
&gt;&gt;<br>
&gt;&gt; &gt; Thank you.  I&#39;ve confirmed that if only *one* of the two servers is<br>
&gt;&gt; &gt; unreachable, pgpool behaves as expected (waits for the server to be<br>
&gt;&gt; &gt; manually reattached).<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Although I wonder also, even if pgpool *did* correctly refuse to send<br>
&gt;&gt; &gt; traffic if both servers were &quot;down&quot; in pgpool_status on restart, how<br>
&gt;&gt; &gt; should we know in which direction to recover data (from A to B or B to<br>
&gt;&gt; &gt; A)?  Pgpool does not record in pgpool_status which &quot;down&quot; server was<br>
&gt;&gt; &gt; the last to go down (and is thus authoritative).  As a workaround I<br>
&gt;&gt; &gt; think it would work to write a failover/failback_command which records<br>
&gt;&gt; &gt; this information.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Wed, Aug 5, 2015 at 6:59 PM, Tatsuo Ishii &lt;<a href="mailto:ishii@postgresql.org">ishii@postgresql.org</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt; Pgpool should recognize that both A and B are in down status, but<br>
&gt;&gt; &gt;&gt; actually not. Let me investigate...<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Best regards,<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" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
&gt;&gt; &gt;&gt; Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Consider the following sequence, starting from a healthy system of two<br>
&gt;&gt; &gt;&gt;&gt; PG servers (A and B) joined in &quot;replication&quot; mode:<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; 1) Server A loses connectivity.<br>
&gt;&gt; &gt;&gt;&gt; 2) A write comes in, which pgpool commits to server B.<br>
&gt;&gt; &gt;&gt;&gt; 3) Server B loses connectivity.<br>
&gt;&gt; &gt;&gt;&gt; 4) Server A regains connectivity.<br>
&gt;&gt; &gt;&gt;&gt; 5) pgpool restarts (due to either sysadmin action or failure).<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; At this point, pgpool happily directs all traffic to server A, which<br>
&gt;&gt; &gt;&gt;&gt; does *not* have the most recent commit to server B.  This is very bad<br>
&gt;&gt; &gt;&gt;&gt; since I have now lost data consistency.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Rather, I would expect that pgpool remembers that it has written data<br>
&gt;&gt; &gt;&gt;&gt; to B but not to A, and would refuse incoming connections until A has<br>
&gt;&gt; &gt;&gt;&gt; been recovered from B.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Even to workaround, if before restarting pgpool, I had some tool which<br>
&gt;&gt; &gt;&gt;&gt; checked the state in which pgpool left the two servers and then<br>
&gt;&gt; &gt;&gt;&gt; rectified them, that would suffice.  However since pgpool doesn&#39;t seem<br>
&gt;&gt; &gt;&gt;&gt; to track at all the fact that it had written some data only to B but<br>
&gt;&gt; &gt;&gt;&gt; not to A, that information is not available (e.g. from pgpool_status).<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; What am I missing?  How is it that others use pgpool in &quot;replication&quot;<br>
&gt;&gt; &gt;&gt;&gt; mode without encountering data inconsistencies when nodes fail?<br>
&gt;&gt; &gt;&gt;&gt; _______________________________________________<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/listinfo/pgpool-general</a><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; pgpool-general mailing list<br>
&gt;&gt; <a href="mailto:pgpool-general@pgpool.net">pgpool-general@pgpool.net</a><br>
&gt;&gt; <a href="http://www.pgpool.net/mailman/listinfo/pgpool-general" rel="noreferrer" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-general</a><br>
&gt;&gt;<br>
</div></div></blockquote></div><br></div>