<div dir="ltr">Hi Ishii-San<div><br></div><div>Please fine the updated patch, It fixes the regression issue you were facing and also another bug which I encountered during my testing.</div><div><br></div><div>-- Adding Yugo to the thread,</div><div>Hi Yugo,</div><div><br></div><div>Since you are an expert of watchdog feature, So I thought you might have something to say especially regarding the discussion points mentioned in the initial mail.</div><div><br></div><div><br></div><div>Thanks</div><div>Best Regards</div><div>Muhammad Usama</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 24, 2017 at 11:25 AM, Muhammad Usama <span dir="ltr">&lt;<a href="mailto:m.usama@gmail.com" target="_blank">m.usama@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"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Aug 24, 2017 at 4:34 AM, 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">After applying the patch, many of regression tests fail. It seems<br>
pgpool.conf.sample has bogus comment which causes the pgpool.conf<br>
parser to complain parse error.<br>
<br>
2017-08-24 08:22:36: pid 6017: FATAL:  syntex error in configuration file &quot;/home/t-ishii/work/pgpool-II/<wbr>current/pgpool2/src/test/regre<wbr>ssion/tests/004.watchdog/stand<wbr>by/etc/pgpool.conf&quot;<br>
2017-08-24 08:22:36: pid 6017: DETAIL:  parse error at line 568 &#39;*&#39; token = 8<br></blockquote><div><br></div></span><div>Really sorry, Somehow I overlooked the sample config file changes I made at the last minute.</div><div>Will send you the updated version.</div><span class=""><div><br></div><div>Thanks</div><div>Best Regards</div><div>Muhammad Usama</div></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="m_6998839053732453560h5"><br><div><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_<wbr>en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.<wbr>jp</a><br>
<br>
&gt; Usama,<br>
&gt;<br>
&gt; Thanks for the patch. I am going to review it.<br>
&gt;<br>
&gt; In the mean time when I apply your patch, I got some trailing<br>
&gt; whitespace errors. Can you please fix them?<br>
&gt;<br>
&gt; /home/t-ishii/quorum_aware_fai<wbr>lover.diff:470: trailing whitespace.<br>
&gt;<br>
&gt; /home/t-ishii/quorum_aware_fai<wbr>lover.diff:485: trailing whitespace.<br>
&gt;<br>
&gt; /home/t-ishii/quorum_aware_fai<wbr>lover.diff:564: trailing whitespace.<br>
&gt;<br>
&gt; /home/t-ishii/quorum_aware_fai<wbr>lover.diff:1428: trailing whitespace.<br>
&gt;<br>
&gt; /home/t-ishii/quorum_aware_fai<wbr>lover.diff:1450: trailing whitespace.<br>
&gt;<br>
&gt; warning: squelched 3 whitespace errors<br>
&gt; warning: 8 lines add whitespace errors.<br>
&gt;<br>
&gt; Best regards,<br>
&gt; --<br>
&gt; Tatsuo Ishii<br>
&gt; SRA OSS, Inc. Japan<br>
&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; Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.<wbr>jp</a><br>
&gt;<br>
&gt;&gt; Hi<br>
&gt;&gt;<br>
&gt;&gt; I was working on the new feature to make the backend node failover quorum<br>
&gt;&gt; aware and on the half way through the implementation I also added the<br>
&gt;&gt; majority consensus feature for the same.<br>
&gt;&gt;<br>
&gt;&gt; So please find the first version of the patch for review that makes the<br>
&gt;&gt; backend node failover consider the watchdog cluster quorum status and seek<br>
&gt;&gt; the majority consensus before performing failover.<br>
&gt;&gt;<br>
&gt;&gt; *Changes in the Failover mechanism with watchdog.*<br>
&gt;&gt; For this new feature I have modified the Pgpool-II&#39;s existing failover<br>
&gt;&gt; mechanism with watchdog.<br>
&gt;&gt; Previously as you know when the Pgpool-II require to perform a node<br>
&gt;&gt; operation (failover, failback, promote-node) with the watchdog. The<br>
&gt;&gt; watchdog used to propagated the failover request to all the Pgpool-II nodes<br>
&gt;&gt; in the watchdog cluster and as soon as the request was received by the<br>
&gt;&gt; node, it used to initiate the local failover and that failover was<br>
&gt;&gt; synchronised on all nodes using the distributed locks.<br>
&gt;&gt;<br>
&gt;&gt; *Now Only the Master node performs the failover.*<br>
&gt;&gt; The attached patch changes the mechanism of synchronised failover, and now<br>
&gt;&gt; only the Pgpool-II of master watchdog node performs the failover, and all<br>
&gt;&gt; other standby nodes sync the backend statuses after the master Pgpool-II is<br>
&gt;&gt; finished with the failover.<br>
&gt;&gt;<br>
&gt;&gt; *Overview of new failover mechanism.*<br>
&gt;&gt; -- If the failover request is received to the standby watchdog node(from<br>
&gt;&gt; local Pgpool-II), That request is forwarded to the master watchdog and the<br>
&gt;&gt; Pgpool-II main process is returned with the FAILOVER_RES_WILL_BE_DONE<br>
&gt;&gt; return code. And upon receiving the FAILOVER_RES_WILL_BE_DONE from the<br>
&gt;&gt; watchdog for the failover request the requesting Pgpool-II moves forward<br>
&gt;&gt; without doing anything further for the particular failover command.<br>
&gt;&gt;<br>
&gt;&gt; -- Now when the failover request from standby node is received by the<br>
&gt;&gt; master watchdog, after performing the validation, applying the consensus<br>
&gt;&gt; rules the failover request is triggered on the local Pgpool-II .<br>
&gt;&gt;<br>
&gt;&gt; -- When the failover request is received to the master watchdog node from<br>
&gt;&gt; the local Pgpool-II (On the IPC channel) the watchdog process inform the<br>
&gt;&gt; Pgpool-II requesting process to proceed with failover (provided all<br>
&gt;&gt; failover rules are satisfied).<br>
&gt;&gt;<br>
&gt;&gt; -- After the failover is finished on the master Pgpool-II, the failover<br>
&gt;&gt; function calls the *wd_failover_end*() which sends the backend sync<br>
&gt;&gt; required message to all standby watchdogs.<br>
&gt;&gt;<br>
&gt;&gt; -- Upon receiving the sync required message from master watchdog node all<br>
&gt;&gt; Pgpool-II sync the new statuses of each backend node from the master<br>
&gt;&gt; watchdog.<br>
&gt;&gt;<br>
&gt;&gt; *No More Failover locks*<br>
&gt;&gt; Since with this new failover mechanism we do not require any<br>
&gt;&gt; synchronisation and guards against the execution of failover_commands by<br>
&gt;&gt; multiple Pgpool-II nodes, So the patch removes all the distributed locks<br>
&gt;&gt; from failover function, This makes the failover simpler and faster.<br>
&gt;&gt;<br>
&gt;&gt; *New kind of Failover operation NODE_QUARANTINE_REQUEST*<br>
&gt;&gt; The patch adds the new kind of backend node operation NODE_QUARANTINE which<br>
&gt;&gt; is effectively same as the NODE_DOWN, but with node_quarantine the<br>
&gt;&gt; failover_command is not triggered.<br>
&gt;&gt; The NODE_DOWN_REQUEST is automatically converted to the<br>
&gt;&gt; NODE_QUARANTINE_REQUEST when the failover is requested on the backend node<br>
&gt;&gt; but watchdog cluster does not holds the quorum.<br>
&gt;&gt; This means in the absence of quorum the failed backend nodes are<br>
&gt;&gt; quarantined and when the quorum becomes available again the Pgpool-II<br>
&gt;&gt; performs the failback operation on all quarantine nodes.<br>
&gt;&gt; And again when the failback is performed on the quarantine backend node the<br>
&gt;&gt; failover function does not trigger the failback_command.<br>
&gt;&gt;<br>
&gt;&gt; *Controlling the Failover behaviour.*<br>
&gt;&gt; The patch adds three new configuration parameters to configure the failover<br>
&gt;&gt; behaviour from user side.<br>
&gt;&gt;<br>
&gt;&gt; *failover_when_quorum_exists*<br>
&gt;&gt; When enabled the failover command will only be executed when the watchdog<br>
&gt;&gt; cluster holds the quorum. And when the quorum is absent and<br>
&gt;&gt; failover_when_quorum_exists is enabled the failed backend nodes will get<br>
&gt;&gt; quarantine until the quorum becomes available again.<br>
&gt;&gt; disabling it will enable the old behaviour of failover commands.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; *failover_require_consensus*Th<wbr>is new configuration parameter can be used to<br>
&gt;&gt; make sure we get the majority vote before performing the failover on the<br>
&gt;&gt; node. When *failover_require_consensus* is enabled then the failover is<br>
&gt;&gt; only performed after receiving the failover request from the majority or<br>
&gt;&gt; Pgpool-II nodes.<br>
&gt;&gt; For example in three nodes cluster the failover will not be performed until<br>
&gt;&gt; at least two nodes ask for performing the failover on the particular<br>
&gt;&gt; backend node.<br>
&gt;&gt;<br>
&gt;&gt; It is also worthwhile to mention here that *failover_require_consensus*<br>
&gt;&gt; only works when failover_when_quorum_exists is enables.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; *enable_multiple_failover_requ<wbr>ests_from_node*<br>
&gt;&gt; This parameter works in connection with *failover_require_consensus*<br>
&gt;&gt; config. When enabled a single Pgpool-II node can vote for failover multiple<br>
&gt;&gt; times.<br>
&gt;&gt; For example in the three nodes cluster if one Pgpool-II node sends the<br>
&gt;&gt; failover request of particular node twice that would be counted as two<br>
&gt;&gt; votes in favour of failover and the failover will be performed even if we<br>
&gt;&gt; do not get a vote from other two nodes.<br>
&gt;&gt;<br>
&gt;&gt; And when *enable_multiple_failover_requ<wbr>ests_from_node* is disabled, Only<br>
&gt;&gt; the first vote from each Pgpool-II will be accepted and all other<br>
&gt;&gt; subsequent votes will be marked duplicate and rejected.<br>
&gt;&gt; So in that case we will require a majority votes from distinct nodes to<br>
&gt;&gt; execute the failover.<br>
&gt;&gt; Again this *enable_multiple_failover_requ<wbr>ests_from_node* only becomes<br>
&gt;&gt; effective when both *failover_when_quorum_exists* and<br>
&gt;&gt; *failover_require_consensus* are enabled.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; *Controlling the failover: The Coding perspective.*<br>
&gt;&gt; Although the failover functions are made quorum and consensus aware but<br>
&gt;&gt; there is still a way to bypass the quorum conditions, and requirement of<br>
&gt;&gt; consensus.<br>
&gt;&gt;<br>
&gt;&gt; For this the patch uses the existing request_details flags in<br>
&gt;&gt; POOL_REQUEST_NODE to control the behaviour of failover.<br>
&gt;&gt;<br>
&gt;&gt; Here are the newly added flags values.<br>
&gt;&gt;<br>
&gt;&gt; *REQ_DETAIL_WATCHDOG*:<br>
&gt;&gt; Setting this flag while issuing the failover command will not send the<br>
&gt;&gt; failover request to the watchdog. But this flag may not be useful in any<br>
&gt;&gt; other place than where it is already used.<br>
&gt;&gt; Mostly this flag can be used to avoid the failover command from going to<br>
&gt;&gt; watchdog that is already originated from watchdog. Otherwise we can end up<br>
&gt;&gt; in infinite loop.<br>
&gt;&gt;<br>
&gt;&gt; *REQ_DETAIL_CONFIRMED*:<br>
&gt;&gt; Setting this flag will bypass the *failover_require_consensus*<br>
&gt;&gt; configuration and immediately perform the failover if quorum is present.<br>
&gt;&gt; This flag can be used to issue the failover request originated from PCP<br>
&gt;&gt; command.<br>
&gt;&gt;<br>
&gt;&gt; *REQ_DETAIL_UPDATE*:<br>
&gt;&gt; This flag is used for the command where we are failing back the quarantine<br>
&gt;&gt; nodes. Setting this flag will not trigger the failback_command.<br>
&gt;&gt;<br>
&gt;&gt; *Some conditional flags used:*<br>
&gt;&gt; I was not sure about the configuration of each type of failover operation.<br>
&gt;&gt; As we have three main failover operations NODE_UP_REQUEST,<br>
&gt;&gt; NODE_DOWN_REQUEST, and PROMOTE_NODE_REQUEST<br>
&gt;&gt; So I was thinking do we need to give the configuration option to the users,<br>
&gt;&gt; if they want to enable/disable quorum checking and consensus for individual<br>
&gt;&gt; failover operation type.<br>
&gt;&gt; For example: is it a practical configuration where a user would want to<br>
&gt;&gt; ensure quorum while preforming NODE_DOWN operation while does not want it<br>
&gt;&gt; for NODE_UP.<br>
&gt;&gt; So in this patch I use three compile time defines to enable disable the<br>
&gt;&gt; individual failover operation, while we can decide on the best solution.<br>
&gt;&gt;<br>
&gt;&gt; NODE_UP_REQUIRE_CONSENSUS: defining it will enable quorum checking feature<br>
&gt;&gt; for NODE_UP_REQUESTs<br>
&gt;&gt;<br>
&gt;&gt; NODE_DOWN_REQUIRE_CONSENSUS: defining it will enable quorum checking<br>
&gt;&gt; feature for NODE_DOWN_REQUESTs<br>
&gt;&gt;<br>
&gt;&gt; NODE_PROMOTE_REQUIRE_CONSENSUS<wbr>: defining it will enable quorum checking<br>
&gt;&gt; feature for PROMOTE_NODE_REQUESTs<br>
&gt;&gt;<br>
&gt;&gt; *Some Point for Discussion:*<br>
&gt;&gt;<br>
&gt;&gt; *Do we really need to check ReqInfo-&gt;switching flag before enqueuing<br>
&gt;&gt; failover request.*<br>
&gt;&gt; While working on the patch I was wondering why do we disallow enqueuing the<br>
&gt;&gt; failover command when the failover is already in progress? For example in<br>
&gt;&gt; *pcp_process_command*() function if we see the *Req_info-&gt;switching* flag<br>
&gt;&gt; set we bailout with the error instead of enqueuing the command. Is is<br>
&gt;&gt; really necessary?<br>
&gt;&gt;<br>
&gt;&gt; *Do we need more granule control over each failover operation:*<br>
&gt;&gt; As described in section &quot;Some conditional flags used&quot; I want the opinion on<br>
&gt;&gt; do we need configuration parameters in pgpool.conf to enable disable quorum<br>
&gt;&gt; and consensus checking on individual failover types.<br>
&gt;&gt;<br>
&gt;&gt; *Which failover should be mark as Confirmed:*<br>
&gt;&gt; As defined in the above section of REQ_DETAIL_CONFIRMED, We can mark the<br>
&gt;&gt; failover request to not need consensus, currently the requests from the PCP<br>
&gt;&gt; commands are fired with this flag. But I was wondering there may be more<br>
&gt;&gt; places where we many need to use the flag.<br>
&gt;&gt; For example I currently use the same confirmed flag when failover is<br>
&gt;&gt; triggered because of *replication_stop_on_mismatch*<wbr>.<br>
&gt;&gt;<br>
&gt;&gt; I think we should think this flag for each place of failover, like when the<br>
&gt;&gt; failover is triggered<br>
&gt;&gt; because of health_check failure.<br>
&gt;&gt; because of replication mismatch<br>
&gt;&gt; because of backend_error<br>
&gt;&gt; e.t.c<br>
&gt;&gt;<br>
&gt;&gt; *Node Quarantine behaviour.*<br>
&gt;&gt; What do you think about the node quarantine used by this patch. Can you<br>
&gt;&gt; think of some problem which can be caused by this?<br>
&gt;&gt;<br>
&gt;&gt; *What should be the default values for each newly added config parameters.*<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; *TODOs*<br>
&gt;&gt;<br>
&gt;&gt; -- Updating the documentation is still todo. Will do that once every aspect<br>
&gt;&gt; of the feature will be finalised.<br>
&gt;&gt; -- Some code warnings and cleanups are still not done.<br>
&gt;&gt; -- I am still little short on testing<br>
&gt;&gt; -- Regression test cases for the feature<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Thoughts and suggestions are most welcome.<br>
&gt;&gt;<br>
&gt;&gt; Thanks<br>
&gt;&gt; Best regards<br>
&gt;&gt; Muhammad Usama<br>
</div></div></div></div><div><div class="h5">&gt; ______________________________<wbr>_________________<br>
&gt; pgpool-hackers mailing list<br>
&gt; <a href="mailto:pgpool-hackers@pgpool.net" target="_blank">pgpool-hackers@pgpool.net</a><br>
&gt; <a href="http://www.pgpool.net/mailman/listinfo/pgpool-hackers" rel="noreferrer" target="_blank">http://www.pgpool.net/mailman/<wbr>listinfo/pgpool-hackers</a><br>
</div></div></blockquote></div><br></div></div>
</blockquote></div><br></div>