<div dir="ltr">Hi Tatsuo,<div><br></div><div>Thanks for the detailed explanation. But I&#39;m not expecting this. It is not in my hands if pg1 reboots for some reason. I was assuming that pg2 should continue to be master and pgpool should send the requests to pg2 until another failover occurs. And at any point of time, we should not have 2 masters. How can we avoid this situation? If we have 3 postgres nodes, will it solve the problem?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 1, 2020 at 11:36 AM 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; Hi Tatsuo,<br>
&gt; <br>
&gt; Thanks for letting me know the process. Just curious to know what will<br>
&gt; happen if pg1 reboots and comes back and in the meanwhile pg2 got promoted<br>
&gt; as master. What is the expectation in this situation ?<br>
<br>
When pg1 shudown, failover process will mark pg1 as down, and pg2 gets<br>
promoted to primary. So you have:<br>
<br>
pg1: down, standby<br>
pg2: up, primary<br>
<br>
So far, so good. BUT if you restart whole system, you will find that:<br>
<br>
pg1: up, primary<br>
pg2: up, standby<br>
<br>
Becuase both pg1 and pg2 are primary and there&#39;s no other info to<br>
decide which one is the true primary. In this case pgpool decides that<br>
the first node, which is not standby, to be primary.<br>
<br>
Actually p2 is not standby, and you will get into trouble because pg2<br>
is not a standby synched with pg1. (you will see huge<br>
relplication_delay).<br>
<br>
If you turn on detach_false_primary, pgpool will find that pg2 is not<br>
a standby and make it down.<br>
<br>
&gt; On Tue, Sep 1, 2020 at 10:32 AM 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; Hi Tatsuo,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks for your email. Yes, I have read the message and fixed the pcp<br>
&gt;&gt; &gt; authentication issue.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Now, I&#39;m facing a different issue. I will try to explain it step by step.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Sequence:<br>
&gt;&gt; &gt; 1. pg1 is primary and pg2 is standby<br>
&gt;&gt; &gt; 2. Stop postgres service on pg1<br>
&gt;&gt; &gt; 3. Pgpool executes failover<br>
&gt;&gt; &gt; 4. Now pg2 is my primary. I verified all the configurations.<br>
&gt;&gt; &gt; 5. Started postgres service on pg1<br>
&gt;&gt; &gt; 6. Trying to recover failed node<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; postgres@ip-172-31-39-241:/etc/pgpool2/4.0.9$ pcp_recovery_node -h<br>
&gt;&gt; &gt; localhost -p 9898 -n 0<br>
&gt;&gt; &gt; Password:<br>
&gt;&gt; &gt; ERROR:  process recovery request failed<br>
&gt;&gt; &gt; DETAIL:  primary server cannot be recovered by online recovery.<br>
&gt;&gt;<br>
&gt;&gt; You shoud have not started pg1 postgres at this<br>
&gt;&gt; point. pcp_recovery_node should not be executed on running node. See<br>
&gt;&gt; the manual:<br>
&gt;&gt;<br>
&gt;&gt; Note: The recovery target PostgreSQL server must not be running for<br>
&gt;&gt; performing the online recovery. If the target PostgreSQL server has<br>
&gt;&gt; already started, you must shut it down before starting the online<br>
&gt;&gt; recovery.<br>
&gt;&gt;<br>
&gt;&gt; If you have not started pg1 then pcp_recovert_node would succeed.<br>
&gt;&gt;<br>
&gt;&gt; &gt; Log says verify_backend_node_status: decided node 0 is the true primary<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; This command hangs<br>
&gt;&gt; &gt; psql -U postgres -h localhost -p 9999 --pset pager=off -c &quot;show<br>
&gt;&gt; pool_nodes&quot;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I would like to know how pgpool is considering node 0 which is pg1 as<br>
&gt;&gt; true<br>
&gt;&gt; &gt; primary ?<br>
&gt;&gt;<br>
&gt;&gt; Because pgpool thinks the first primary node found is the true primary<br>
&gt;&gt; node if there is<br>
&gt;&gt;<br>
&gt;&gt; &gt; Then what did I do ?<br>
&gt;&gt; &gt; 1. Cleaned everything on pg1 and manually configured it as standby.<br>
&gt;&gt; &gt; 2. Started postgres service<br>
&gt;&gt; &gt; 3. Log says<br>
&gt;&gt; &gt; 2020-08-31 13:40:00: pid 2459: DEBUG:  do_query: extended:0 query:&quot;SELECT<br>
&gt;&gt; &gt; pg_is_in_recovery()&quot;<br>
&gt;&gt; &gt; 2020-08-31 13:40:00: pid 2459: DEBUG:  verify_backend_node_status:<br>
&gt;&gt; there&#39;s<br>
&gt;&gt; &gt; no standby node<br>
&gt;&gt; &gt; 2020-08-31 13:40:00: pid 2459: DEBUG:  node status[0]: 0<br>
&gt;&gt; &gt; 2020-08-31 13:40:00: pid 2459: DEBUG:  node status[1]: 1<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; This command executes now<br>
&gt;&gt; &gt; postgres@ip-172-31-39-241:/etc/pgpool2/4.0.9$ psql -U postgres -h<br>
&gt;&gt; localhost<br>
&gt;&gt; &gt; -p 9999 --pset pager=off -c &quot;show pool_nodes&quot;<br>
&gt;&gt; &gt;  node_id | hostname | port | status | lb_weight |  role   | select_cnt |<br>
&gt;&gt; &gt; load_balance_node | replication_delay | last_status_change<br>
&gt;&gt; &gt;<br>
&gt;&gt; ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+---------------------<br>
&gt;&gt; &gt;  0       | pg1      | 5432 | down   | 0.500000  | standby | 0          |<br>
&gt;&gt; &gt; false             | 0                 | 2020-08-31 13:35:44<br>
&gt;&gt; &gt;  1       | pg2      | 5432 | up     | 0.500000  | primary | 0          |<br>
&gt;&gt; &gt; true              | 0                 | 2020-08-31 13:35:44<br>
&gt;&gt; &gt; (2 rows)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I checked between pg1 and pg2 and see that streaming replication is<br>
&gt;&gt; working.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Then I used pcp_attach_node to attach standby<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; postgres@ip-172-31-39-241:/etc/pgpool2/4.0.9$ pcp_attach_node -h<br>
&gt;&gt; localhost<br>
&gt;&gt; &gt; -p 9898 -n 0<br>
&gt;&gt; &gt; Password:<br>
&gt;&gt; &gt; pcp_attach_node -- Command Successful<br>
&gt;&gt; &gt; postgres@ip-172-31-39-241:/etc/pgpool2/4.0.9$ psql -U postgres -h<br>
&gt;&gt; localhost<br>
&gt;&gt; &gt; -p 9999 --pset pager=off -c &quot;show pool_nodes&quot;<br>
&gt;&gt; &gt;  node_id | hostname | port | status | lb_weight |  role   | select_cnt |<br>
&gt;&gt; &gt; load_balance_node | replication_delay | last_status_change<br>
&gt;&gt; &gt;<br>
&gt;&gt; ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+---------------------<br>
&gt;&gt; &gt;  0       | pg1      | 5432 | up     | 0.500000  | standby | 0          |<br>
&gt;&gt; &gt; true              | 0                 | 2020-08-31 14:09:31<br>
&gt;&gt; &gt;  1       | pg2      | 5432 | up     | 0.500000  | primary | 0          |<br>
&gt;&gt; &gt; false             | 0                 | 2020-08-31 14:02:35<br>
&gt;&gt; &gt; (2 rows)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Then I tried to perform a test operation and it executed successfully.<br>
&gt;&gt; &gt; postgres@ip-172-31-39-241:/etc/pgpool2/4.0.9$ psql -U postgres -h<br>
&gt;&gt; localhost<br>
&gt;&gt; &gt; -p 9999 --pset pager=off -c &quot;create database covid&quot;<br>
&gt;&gt; &gt; CREATE DATABASE<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Am I missing something in this failover process ? Please let me know if<br>
&gt;&gt; you<br>
&gt;&gt; &gt; need any additional details.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Tue, Sep 1, 2020 at 3:03 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; Praveen,<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Have you read this message? I wonder if you have fixed the issue or not.<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; From: Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt;<br>
&gt;&gt; &gt;&gt; Subject: [pgpool-general: 7208] Re: Query regarding failover and<br>
&gt;&gt; recovery<br>
&gt;&gt; &gt;&gt; Date: Thu, 20 Aug 2020 08:51:04 +0900 (JST)<br>
&gt;&gt; &gt;&gt; Message-ID: &lt;<a href="mailto:20200820.085104.891242161358675858.t-ishii@sraoss.co.jp" target="_blank">20200820.085104.891242161358675858.t-ishii@sraoss.co.jp</a>&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; The contents of pcp.conf looks incorrect.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; postgres:md53175bce1d3201d16594cebf9d7eb3f9d<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; The hashed password must not start with &quot;md5&quot;.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; To create proper pcp password, please follow the instruction in the<br>
&gt;&gt; &gt;&gt; manual:<br>
&gt;&gt; &gt;&gt; &gt; <a href="https://www.pgpool.net/docs/40/en/html/configuring-pcp-conf.html" rel="noreferrer" target="_blank">https://www.pgpool.net/docs/40/en/html/configuring-pcp-conf.html</a><br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Hello,<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Thanks for the clarification. I&#39;m trying to execute and getting below<br>
&gt;&gt; &gt;&gt; &gt;&gt; error. I&#39;m attaching configs for your reference. Can you please help<br>
&gt;&gt; ?<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; postgres@pgp1:/etc/pgpool2/4.0.9$ psql -U postgres -h localhost -p<br>
&gt;&gt; 9999<br>
&gt;&gt; &gt;&gt; &gt;&gt; --pset pager=off -c &quot;show pool_nodes&quot;<br>
&gt;&gt; &gt;&gt; &gt;&gt;  node_id | hostname | port | status | lb_weight |  role   |<br>
&gt;&gt; select_cnt |<br>
&gt;&gt; &gt;&gt; &gt;&gt; load_balance_node | replication_delay | last_status_change<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+---------------------<br>
&gt;&gt; &gt;&gt; &gt;&gt;  0       | pg1      | 5432 | down   | 0.500000  | standby | 0<br>
&gt;&gt;   |<br>
&gt;&gt; &gt;&gt; &gt;&gt; false             | 0                 | 2020-08-19 09:02:46<br>
&gt;&gt; &gt;&gt; &gt;&gt;  1       | pg2      | 5432 | up     | 0.500000  | primary | 0<br>
&gt;&gt;   |<br>
&gt;&gt; &gt;&gt; &gt;&gt; true              | 0                 | 2020-08-19 09:02:46<br>
&gt;&gt; &gt;&gt; &gt;&gt; (2 rows)<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; postgres@pgp1:/etc/pgpool2/4.0.9$<br>
&gt;&gt; &gt;&gt; &gt;&gt; postgres@pgp1:/etc/pgpool2/4.0.9$<br>
&gt;&gt; &gt;&gt; &gt;&gt; postgres@pgp1:/etc/pgpool2/4.0.9$<br>
&gt;&gt; &gt;&gt; &gt;&gt; postgres@pgp1:/etc/pgpool2/4.0.9$ pcp_recovery_node -h localhost -p<br>
&gt;&gt; &gt;&gt; 9898 -n<br>
&gt;&gt; &gt;&gt; &gt;&gt; 0<br>
&gt;&gt; &gt;&gt; &gt;&gt; Password:<br>
&gt;&gt; &gt;&gt; &gt;&gt; FATAL:  authentication failed for user &quot;postgres&quot;<br>
&gt;&gt; &gt;&gt; &gt;&gt; DETAIL:  username and/or password does not match<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; postgres@pgp1:/etc/pgpool2/4.0.9$<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; On Wed, Aug 19, 2020 at 10:22 AM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt;<br>
&gt;&gt; &gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; I have 3 servers with two postgres (9.6) and one pgpool (4.0.9).<br>
&gt;&gt; &gt;&gt; Postgres<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; is configured with streaming replication.<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; When I manually stop postgres service on primary node, failover<br>
&gt;&gt; has<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; happened successfully.<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; Now I started postgres service on old primary node which is<br>
&gt;&gt; expected<br>
&gt;&gt; &gt;&gt; to<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; be<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; converted as slave, pgpool is not triggering<br>
&gt;&gt; &gt;&gt; recovery_1st_stage_command =<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; &#39;recovery_1st_stage.sh&#39;<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; &gt; May I know what could be the reason ?<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; That is an expected behavior. The node previously brought down is<br>
&gt;&gt; left<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; as &quot;down&quot; by pgoool. This is intentional. You need to issue<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; pcp_recovery_node against the node (previous primary node in your<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; case) to make it online again.<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; When a node is brought down, there might be a reason: for example<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; needed to repair the hardware. So in general it&#39;s not safe to<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; automatically restart the previously down node.<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; Best regards,<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; --<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; Tatsuo Ishii<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt; SRA OSS, Inc. Japan<br>
&gt;&gt; &gt;&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; &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; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; *Regards,*<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; *K S Praveen KumarM: +91-9986855625 *<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" target="_blank">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; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; *Regards,*<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; *K S Praveen KumarM: +91-9986855625 *<br>
&gt;&gt;<br>
&gt; <br>
&gt; <br>
&gt; -- <br>
&gt; <br>
&gt; <br>
&gt; *Regards,*<br>
&gt; <br>
&gt; <br>
&gt; *K S Praveen KumarM: +91-9986855625 *<br>
_______________________________________________<br>
pgpool-general mailing list<br>
<a href="mailto:pgpool-general@pgpool.net" target="_blank">pgpool-general@pgpool.net</a><br>
<a href="http://www.pgpool.net/mailman/listinfo/pgpool-general" rel="noreferrer" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-general</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><font style="font-family:&quot;courier new&quot;,monospace" size="1"><b style="color:rgb(102,102,102)">Regards,<br><br></b></font><div style="color:rgb(102,102,102)"><font size="1"><b><font face="&#39;comic sans ms&#39;, sans-serif"><font style="font-family:&quot;courier new&quot;,monospace" size="1">K S Praveen Kumar<br>M: +91-9986855625 </font><br></font></b></font></div></div>