<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 16, 2019 at 1:27 PM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt;&gt; Question is, why can&#39;t we automatically recover from detached state as<br>
&gt;&gt; well as quarantine state?<br>
&gt;&gt;<br>
&gt; <br>
&gt; Well ideally we should also automatically recover from detached state as<br>
&gt; well, but the problem<br>
&gt; is that when the node is detached, specifically the primary node, the<br>
&gt; failover procedure<br>
&gt; promotes another standby to make it a new master and follow_master adjusts<br>
&gt; the standby<br>
&gt; nodes to point to the new master. Now even when the old primary that was<br>
&gt; detached becomes<br>
&gt; reachable again, attaching it automatically would lead to the verity of<br>
&gt; problems and split-brain.<br>
&gt; I think it is possible to implement the mechanism to verify the detached<br>
&gt; PostgreSQL node status when it<br>
&gt; becomes reachable again and after taking appropriate actions attach it back<br>
&gt; automatically but currently<br>
&gt; we don&#39;t have anything like that in Pgpool. So we instead rely on user<br>
&gt; intervention to do the re-attach<br>
&gt; using pcp_attach_node or online recovery mechanisms.<br>
&gt; <br>
&gt; Now if we look at the quarantine nodes, they are just as good as alive<br>
&gt; nodes (but unreachable by pgpool at the moment).<br>
&gt; Because when the node was quarantined, Pgpool-II never executed any<br>
&gt; failover and/or follow_master commands<br>
&gt; and did not interfered with the PostgreSQL backend in any way to alter its<br>
&gt; timeline or recovery states,<br>
&gt; So when the quarantine node becomes reachable again it is safe to<br>
&gt; automatically connect them back to the Pgpool-II<br>
<br>
Ok, that makes sense.<br>
<br>
&gt;&gt; &gt;&gt; BTW,<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; &gt; When the communication between master/coordinator pgpool and<br>
&gt;&gt; &gt;&gt; &gt; &gt; primary PostgreSQL node is down during a short period<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; I wonder why you don&#39;t set appropriate health check retry parameters<br>
&gt;&gt; &gt;&gt; &gt; to avoid such a temporary communication failure in the firs place. A<br>
&gt;&gt; &gt;&gt; &gt; brain surgery to ignore the error reports from Pgpool-II does not seem<br>
&gt;&gt; &gt;&gt; &gt; to be a sane choice.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; The original reporter didn&#39;t answer my question. I think it is likely<br>
&gt;&gt; &gt;&gt; a problem of misconfiguraton (should use longer heath check retry).<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; In summary I think for shorter period communication failure just<br>
&gt;&gt; &gt;&gt; increasing health check parameters is enough. However for longer<br>
&gt;&gt; &gt;&gt; period communication failure, the watchdog node should decline the<br>
&gt;&gt; &gt;&gt; role.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I am sorry I didn&#39;t totally get it what you mean here.<br>
&gt;&gt; &gt; Do you mean that the pgpool-II node that has the primary node in<br>
&gt;&gt; quarantine<br>
&gt;&gt; &gt; state should resign from the master/coordinator<br>
&gt;&gt; &gt; pgpool-II node (if it was a master/coordinator) in that case?<br>
&gt;&gt;<br>
&gt;&gt; Yes, exactly. Note that if the PostgreSQL node is one of standbys,<br>
&gt;&gt; keeping the quarantine state is fine because users query could be<br>
&gt;&gt; processed.<br>
&gt;&gt;<br>
&gt; <br>
&gt; Yes that makes total sense. I will make that change as separate patch.<br>
<br>
Thanks. However this will change existing behavior. Probably we should<br>
make the change against master branch only?<br></blockquote><div><br></div><div>Probably yes, because the current fix I have for this in my mind involves the configurable timeout parameter</div><div>to make the master pgpool resign. Let me come up with the patch and then we work on the part of that</div><div>needs to be back ported.</div><div>And regarding the patch I shared upthread to continue the health check on quarantined nodes, Do you think we should</div><div>also back-patch it to older versions as-well ?</div><div><br></div><div>Thanks</div><div>Best Regards</div><div>Muhammad Usama</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt; Thanks<br>
&gt; Best Regards<br>
&gt; Muhammad Usama<br>
&gt; <br>
&gt; <br>
&gt;&gt; &gt; Thanks<br>
&gt;&gt; &gt; Best Regards<br>
&gt;&gt; &gt; Muhammad Usama<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; Can you please try out the attached patch, to see if the solution<br>
&gt;&gt; &gt;&gt; works<br>
&gt;&gt; &gt;&gt; &gt;&gt; for<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; the situation?<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; The patch is generated against current master branch.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; Thanks<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; Best Regards<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; Muhammad Usama<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; On Wed, Apr 10, 2019 at 2:04 PM TAKATSUKA Haruka &lt;<br>
&gt;&gt; &gt;&gt; <a href="mailto:harukat@sraoss.co.jp" target="_blank">harukat@sraoss.co.jp</a>&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; Hello, Pgpool developers<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; I found Pgpool-II watchdog is too strict for duplicate failover<br>
&gt;&gt; &gt;&gt; request<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; with allow_multiple_failover_requests_from_node=off setting.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; For example, A watchdog cluster with 3 pgpool instances is here.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; Their backends are PostgreSQL servers using streaming replication.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; When the communication between master/coordinator pgpool and<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; primary PostgreSQL node is down during a short period<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; (or pgpool do any false-positive judgement by various reasons),<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; and then the pgpool tries to failover but cannot get the<br>
&gt;&gt; consensus,<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; so it makes the primary node into quarantine status. It cannot<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; be reset automatically. As a result, the service becomes<br>
&gt;&gt; unavailable.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; This case generates logs like the following:<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  new IPC connection received<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  watchdog received the failover command from local<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pgpool-II on IPC interface<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  watchdog is processing the failover command<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; [DEGENERATE_BACKEND_REQUEST] received from local pgpool-II on IPC<br>
&gt;&gt; &gt;&gt; &gt;&gt; interface<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  Duplicate failover request from &quot;pg1:5432 Linux<br>
&gt;&gt; pg1&quot;<br>
&gt;&gt; &gt;&gt; &gt;&gt; node<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 1234: DETAIL:  request ignored<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  failover requires the majority vote, waiting for<br>
&gt;&gt; &gt;&gt; &gt;&gt; consensus<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 1234: DETAIL:  failover request noted<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 4321: LOG:  degenerate backend request for 1 node(s) from pid<br>
&gt;&gt; &gt;&gt; &gt;&gt; [4321],<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; is changed to quarantine node request by watchdog<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pid 4321: DETAIL:  watchdog is taking time to build consensus<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; Note that this case dosen&#39;t have any communication truouble among<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; the Pgpool watchdog nodes.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; You can reproduce it by changing one PostgreSQL&#39;s pg_hba.conf to<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; reject the helth check access from one pgpool node in short<br>
&gt;&gt; period.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; The document don&#39;t say that duplicate failover requests make the<br>
&gt;&gt; node<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; quarantine immediately. I think it should be just igunoring the<br>
&gt;&gt; &gt;&gt; request.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; A patch file for head of V3_7_STABLE is attached.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; Pgpool with this patch also disturbs failover by single pgpool&#39;s<br>
&gt;&gt; &gt;&gt; &gt;&gt; repeated<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; failover requests. But it can recover when the connection trouble<br>
&gt;&gt; is<br>
&gt;&gt; &gt;&gt; &gt;&gt; gone.<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; Does this change have any problem?<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; with best regards,<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; TAKATSUKA Haruka &lt;<a href="mailto:harukat@sraoss.co.jp" target="_blank">harukat@sraoss.co.jp</a>&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; pgpool-hackers mailing list<br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; <a href="mailto:pgpool-hackers@pgpool.net" target="_blank">pgpool-hackers@pgpool.net</a><br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; <a href="http://www.pgpool.net/mailman/listinfo/pgpool-hackers" rel="noreferrer" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-hackers</a><br>
&gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt;<br>
</blockquote></div></div>