<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 12:49 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; On Tue, Apr 16, 2019 at 12:14 PM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt; wrote:<br>
&gt; <br>
&gt;&gt; &gt; On Tue, Apr 16, 2019 at 7:55 AM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Hi Usama,<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; Hi  TAKATSUKA Haruka,<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Thanks for the patch, But your patch effectively disables the node<br>
&gt;&gt; &gt;&gt; &gt; quarantine, which does&#39;t seems a right way.<br>
&gt;&gt; &gt;&gt; &gt; Since the backend node that was quarantined because of absence of<br>
&gt;&gt; quorum<br>
&gt;&gt; &gt;&gt; &gt; and/or consensus is already un-reachable<br>
&gt;&gt; &gt;&gt; &gt; form the Pgpool-II node, and we don&#39;t want to select it as<br>
&gt;&gt; load-balance<br>
&gt;&gt; &gt;&gt; &gt; node ( in case the node was secondary) or consider it<br>
&gt;&gt; &gt;&gt; &gt; as available when it is not by not marking it as quarantine.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; In my opinion the right way to tackle the issue is  by keep setting<br>
&gt;&gt; the<br>
&gt;&gt; &gt;&gt; &gt; quarantine state as it is done currently  but<br>
&gt;&gt; &gt;&gt; &gt; also keep the health check working on quarantine nodes. So that as<br>
&gt;&gt; soon<br>
&gt;&gt; &gt;&gt; as<br>
&gt;&gt; &gt;&gt; &gt; the connectivity to the<br>
&gt;&gt; &gt;&gt; &gt; quarantined node resumes, it becomes the part of cluster<br>
&gt;&gt; automatically.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; What if the connection failure between the primary PostgreSQL and one<br>
&gt;&gt; &gt;&gt; of Pgpool-II servers is permanent? Doesn&#39;t health checking continues<br>
&gt;&gt; &gt;&gt; forever?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Yes, only for the quarantined PostgreSQL nodes. But I don&#39;t think there<br>
&gt;&gt; is<br>
&gt;&gt; &gt; a problem<br>
&gt;&gt; &gt; in that. As conceptually the quarantine nodes are not failed node (they<br>
&gt;&gt; are<br>
&gt;&gt; &gt; just unusable at that moment)<br>
&gt;&gt; &gt; and taking the node out of quarantine zone shouldn&#39;t require the manual<br>
&gt;&gt; &gt; intervention. So I think its the correct<br>
&gt;&gt; &gt; way to continue the health checking on quarantined nodes.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Do you see an issue with the approach ?<br>
&gt;&gt;<br>
&gt;&gt; Yes. Think about the case when the PostgreSQL node is primary. Users<br>
&gt;&gt; cannot issue write queries while the retrying. The network failure<br>
&gt;&gt; could persist days and the whole database cluster is unusable in the<br>
&gt;&gt; period.<br>
&gt;&gt;<br>
&gt; <br>
&gt; Yes thats true, But not allowing the node to go into quarantine state will<br>
&gt; still not solve it,<br>
&gt; Because the primary would still be unavailable anyway even if we set the<br>
&gt; quarantine state<br>
&gt; or not. So whole idea of this patch is to recover from quarantine state<br>
&gt; automatically as soon as<br>
&gt; the connectivity resumes.<br>
&gt; Similarly failover of that node is again not an option if the user wants to<br>
&gt; do failover only when the<br>
&gt; network consensus exists, otherwise he should just disable<br>
&gt; failover_require_consensus.<br>
<br>
Question is, why can&#39;t we automatically recover from detached state as<br>
well as quarantine state?<br></blockquote><div><br></div><div>Well ideally we should also automatically recover from detached state as well, but the problem</div><div>is that when the node is detached, specifically the primary node, the failover procedure</div><div>promotes another standby to make it a new master and follow_master adjusts the standby</div><div>nodes to point to the new master. Now even when the old primary that was detached becomes</div><div>reachable again, attaching it automatically would lead to the verity of problems and split-brain.</div><div>I think it is possible to implement the mechanism to verify the detached PostgreSQL node status when it</div><div>becomes reachable again and after taking appropriate actions attach it back automatically but currently</div><div>we don&#39;t have anything like that in Pgpool. So we instead rely on user intervention to do the re-attach</div><div>using pcp_attach_node or online recovery mechanisms.</div><div><br></div><div>Now if we look at the quarantine nodes, they are just as good as alive nodes (but unreachable by pgpool at the moment).</div><div>Because when the node was quarantined, Pgpool-II never executed any failover and/or follow_master commands</div><div>and did not interfered with the PostgreSQL backend in any way to alter its timeline or recovery states,</div><div>So when the quarantine node becomes reachable again it is safe to automatically connect them back to the Pgpool-II</div><div><br></div><div><br></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;&gt; BTW,<br>
&gt;&gt;<br>
&gt;&gt; &gt; &gt; When the communication between master/coordinator pgpool and<br>
&gt;&gt; &gt; &gt; primary PostgreSQL node is down during a short period<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I wonder why you don&#39;t set appropriate health check retry parameters<br>
&gt;&gt; &gt; to avoid such a temporary communication failure in the firs place. A<br>
&gt;&gt; &gt; brain surgery to ignore the error reports from Pgpool-II does not seem<br>
&gt;&gt; &gt; to be a sane choice.<br>
&gt;&gt;<br>
&gt;&gt; The original reporter didn&#39;t answer my question. I think it is likely<br>
&gt;&gt; a problem of misconfiguraton (should use longer heath check retry).<br>
&gt;&gt;<br>
&gt;&gt; In summary I think for shorter period communication failure just<br>
&gt;&gt; increasing health check parameters is enough. However for longer<br>
&gt;&gt; period communication failure, the watchdog node should decline the<br>
&gt;&gt; role.<br>
&gt;&gt;<br>
&gt; <br>
&gt; I am sorry I didn&#39;t totally get it what you mean here.<br>
&gt; Do you mean that the pgpool-II node that has the primary node in quarantine<br>
&gt; state should resign from the master/coordinator<br>
&gt; pgpool-II node (if it was a master/coordinator) in that case?<br>
<br>
Yes, exactly. Note that if the PostgreSQL node is one of standbys,<br>
keeping the quarantine state is fine because users query could be<br>
processed.<br></blockquote><div><br></div><div>Yes that makes total sense. I will make that change as separate patch. </div><div><br></div><div>Thanks</div><div>Best Regards</div><div>Muhammad Usama</div><div><br></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;&gt; &gt; Can you please try out the attached patch, to see if the solution<br>
&gt;&gt; works<br>
&gt;&gt; &gt;&gt; for<br>
&gt;&gt; &gt;&gt; &gt; the situation?<br>
&gt;&gt; &gt;&gt; &gt; The patch is generated against current master branch.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Thanks<br>
&gt;&gt; &gt;&gt; &gt; Best Regards<br>
&gt;&gt; &gt;&gt; &gt; Muhammad Usama<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; On Wed, Apr 10, 2019 at 2:04 PM TAKATSUKA Haruka &lt;<br>
&gt;&gt; <a href="mailto:harukat@sraoss.co.jp" target="_blank">harukat@sraoss.co.jp</a>&gt;<br>
&gt;&gt; &gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Hello, Pgpool developers<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; I found Pgpool-II watchdog is too strict for duplicate failover<br>
&gt;&gt; request<br>
&gt;&gt; &gt;&gt; &gt;&gt; with allow_multiple_failover_requests_from_node=off setting.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; For example, A watchdog cluster with 3 pgpool instances is here.<br>
&gt;&gt; &gt;&gt; &gt;&gt; Their backends are PostgreSQL servers using streaming replication.<br>
&gt;&gt; &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;&gt; (or pgpool do any false-positive judgement by various reasons),<br>
&gt;&gt; &gt;&gt; &gt;&gt; and then the pgpool tries to failover but cannot get the consensus,<br>
&gt;&gt; &gt;&gt; &gt;&gt; so it makes the primary node into quarantine status. It cannot<br>
&gt;&gt; &gt;&gt; &gt;&gt; be reset automatically. As a result, the service becomes unavailable.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; This case generates logs like the following:<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  new IPC connection received<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  watchdog received the failover command from local<br>
&gt;&gt; &gt;&gt; &gt;&gt; pgpool-II on IPC interface<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  watchdog is processing the failover command<br>
&gt;&gt; &gt;&gt; &gt;&gt; [DEGENERATE_BACKEND_REQUEST] received from local pgpool-II on IPC<br>
&gt;&gt; &gt;&gt; interface<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  Duplicate failover request from &quot;pg1:5432 Linux pg1&quot;<br>
&gt;&gt; &gt;&gt; node<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 1234: DETAIL:  request ignored<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 1234: LOG:  failover requires the majority vote, waiting for<br>
&gt;&gt; &gt;&gt; consensus<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 1234: DETAIL:  failover request noted<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 4321: LOG:  degenerate backend request for 1 node(s) from pid<br>
&gt;&gt; &gt;&gt; [4321],<br>
&gt;&gt; &gt;&gt; &gt;&gt; is changed to quarantine node request by watchdog<br>
&gt;&gt; &gt;&gt; &gt;&gt; pid 4321: DETAIL:  watchdog is taking time to build consensus<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&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; the Pgpool watchdog nodes.<br>
&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; reject the helth check access from one pgpool node in short period.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; The document don&#39;t say that duplicate failover requests make the node<br>
&gt;&gt; &gt;&gt; &gt;&gt; quarantine immediately. I think it should be just igunoring the<br>
&gt;&gt; request.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; A patch file for head of V3_7_STABLE is attached.<br>
&gt;&gt; &gt;&gt; &gt;&gt; Pgpool with this patch also disturbs failover by single pgpool&#39;s<br>
&gt;&gt; &gt;&gt; repeated<br>
&gt;&gt; &gt;&gt; &gt;&gt; failover requests. But it can recover when the connection trouble is<br>
&gt;&gt; &gt;&gt; gone.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Does this change have any problem?<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; with best regards,<br>
&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; _______________________________________________<br>
&gt;&gt; &gt;&gt; &gt;&gt; pgpool-hackers mailing list<br>
&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; <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;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt;<br>
</blockquote></div></div>