It is not documented that pg_promote can exit standby mode

Started by ikedamshover 5 years ago11 messages
#1ikedamsh
ikedamsh@oss.nttdata.com
1 attachment(s)

Hi, 

The document(high-availability.sgml) says that there are only two ways
to exit standby mode.

 26.2.2. Standby Server Operation
 Standby mode is exited and the server switches to normal operation when
pg_ctl promote is run or a trigger file is found (promote_trigger_file).

But there is another way, by calling pg_promote function.
I think we need to document it, doesn't it?

I attached a patch. Please review and let me know your thoughts.

Regards,
Masahiro Ikeda

Attachments:

0001-fix-doc-about-the-way-to-exit-standby-mode.patchtext/x-diff; name=0001-fix-doc-about-the-way-to-exit-standby-mode.patchDownload
From 719b754c36f4537aaab7c6de1951d7b7ec4759f6 Mon Sep 17 00:00:00 2001
From: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
Date: Tue, 7 Apr 2020 08:34:55 +0900
Subject: [PATCH] fix doc about the way to exit standby mode

---
 doc/src/sgml/high-availability.sgml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml
index 4659b9e..88bf960 100644
--- a/doc/src/sgml/high-availability.sgml
+++ b/doc/src/sgml/high-availability.sgml
@@ -644,8 +644,8 @@ protocol to make nodes agree on a serializable transactional order.
 
    <para>
     Standby mode is exited and the server switches to normal operation
-    when <command>pg_ctl promote</command> is run or a trigger file is found
-    (<varname>promote_trigger_file</varname>). Before failover,
+    when <command>pg_ctl promote</command> is run, <function>pg_promote</function> is called,
+    or a trigger file is found(<varname>promote_trigger_file</varname>). Before failover,
     any WAL immediately available in the archive or in <filename>pg_wal</filename> will be
     restored, but no attempt is made to connect to the master.
    </para>
-- 
1.8.3.1

#2Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: ikedamsh (#1)
Re: It is not documented that pg_promote can exit standby mode

On 2020/04/17 13:11, ikedamsh wrote:

Hi,

The document(high-availability.sgml) says that there are only two ways to exit standby mode.

 26.2.2. Standby Server Operation
 Standby mode is exited and the server switches to normal operation when pg_ctl promote is run or a trigger file is found (promote_trigger_file).

But there is another way, by calling pg_promote function.
I think we need to document it, doesn't it?

I attached a patch. Please review and let me know your thoughts.

Thanks for the report and the patch! It looks good to me.
Barring any objection, I will commit this patch.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

#3Michael Paquier
michael@paquier.xyz
In reply to: Fujii Masao (#2)
Re: It is not documented that pg_promote can exit standby mode

On Fri, Apr 17, 2020 at 01:40:02PM +0900, Fujii Masao wrote:

Thanks for the report and the patch! It looks good to me.
Barring any objection, I will commit this patch.

+1.
--
Michael
#4Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Michael Paquier (#3)
Re: It is not documented that pg_promote can exit standby mode

On Fri, 2020-04-17 at 13:54 +0900, Michael Paquier wrote:

On Fri, Apr 17, 2020 at 01:40:02PM +0900, Fujii Masao wrote:

Thanks for the report and the patch! It looks good to me.
Barring any objection, I will commit this patch.

+1.

+1. That was my omission in the original patch.

Yours,
Laurenz Albe

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fujii Masao (#2)
Re: It is not documented that pg_promote can exit standby mode

Fujii Masao <masao.fujii@oss.nttdata.com> writes:

Thanks for the report and the patch! It looks good to me.
Barring any objection, I will commit this patch.

It might be worth writing "<function>pg_promote()</function> is called"
(adding parentheses) to make it clearer that a function is being
referred to. No objection otherwise.

regards, tom lane

#6Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Tom Lane (#5)
1 attachment(s)
Re: It is not documented that pg_promote can exit standby mode

On 2020/04/18 2:46, Tom Lane wrote:

Fujii Masao <masao.fujii@oss.nttdata.com> writes:

Thanks for the report and the patch! It looks good to me.
Barring any objection, I will commit this patch.

It might be worth writing "<function>pg_promote()</function> is called"
(adding parentheses) to make it clearer that a function is being
referred to. No objection otherwise.

Yes. Also Masahiro-san reported me, off-list, that there are other places
where pg_promote is mentioned without parentheses. I think it's better to
add parentheses there. Attached is the updated version of the patch.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachments:

0001-fix-doc-about-the-way-to-exit-standby-mode_v2.patchtext/plain; charset=UTF-8; name=0001-fix-doc-about-the-way-to-exit-standby-mode_v2.patch; x-mac-creator=0; x-mac-type=0Download
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index a71ca62463..a14df06292 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -4114,7 +4114,7 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
           Specifies a trigger file whose presence ends recovery in the
           standby.  Even if this value is not set, you can still promote
           the standby using <command>pg_ctl promote</command> or calling
-          <function>pg_promote</function>.
+          <function>pg_promote()</function>.
           This parameter can only be set in the <filename>postgresql.conf</filename>
           file or on the server command line.
          </para>
diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml
index 4659b9ef5d..52e47379cc 100644
--- a/doc/src/sgml/high-availability.sgml
+++ b/doc/src/sgml/high-availability.sgml
@@ -644,7 +644,8 @@ protocol to make nodes agree on a serializable transactional order.
 
    <para>
     Standby mode is exited and the server switches to normal operation
-    when <command>pg_ctl promote</command> is run or a trigger file is found
+    when <command>pg_ctl promote</command> is run,
+    <function>pg_promote()</function> is called, or a trigger file is found
     (<varname>promote_trigger_file</varname>). Before failover,
     any WAL immediately available in the archive or in <filename>pg_wal</filename> will be
     restored, but no attempt is made to connect to the master.
@@ -1470,11 +1471,11 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)'
 
    <para>
     To trigger failover of a log-shipping standby server, run
-    <command>pg_ctl promote</command>, call <function>pg_promote</function>,
+    <command>pg_ctl promote</command>, call <function>pg_promote()</function>,
     or create a trigger file with the file name and path specified by the
     <varname>promote_trigger_file</varname>. If you're planning to use
     <command>pg_ctl promote</command> or to call
-    <function>pg_promote</function> to fail over,
+    <function>pg_promote()</function> to fail over,
     <varname>promote_trigger_file</varname> is not required. If you're
     setting up the reporting servers that are only used to offload read-only
     queries from the primary, not for high availability purposes, you don't
#7Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Fujii Masao (#6)
Re: It is not documented that pg_promote can exit standby mode

On 2020/04/20 20:38, Fujii Masao wrote:

On 2020/04/18 2:46, Tom Lane wrote:

Fujii Masao <masao.fujii@oss.nttdata.com> writes:

Thanks for the report and the patch! It looks good to me.
Barring any objection, I will commit this patch.

It might be worth writing "<function>pg_promote()</function> is called"
(adding parentheses) to make it clearer that a function is being
referred to.  No objection otherwise.

Yes. Also Masahiro-san reported me, off-list, that there are other places
where pg_promote is mentioned without parentheses. I think it's better to
add parentheses there. Attached is the updated version of the patch.

Pushed. Thanks!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

#8Masahiro Ikeda
ikedamsh@oss.nttdata.com
In reply to: ikedamsh (#1)
1 attachment(s)
change a function name in a comment correctly

Hi,

There is the comment which related function name is not same.
I attached the patch to fix it. Please review.

Regards,

--
Masahiro Ikeda
NTT DATA CORPORATION

Attachments:

change_a_function_name_in_comment_correctly.patchtext/x-diff; name=change_a_function_name_in_comment_correctly.patchDownload
diff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.c
index 68b01ca68f..3acda32d17 100644
--- a/src/backend/utils/cache/relfilenodemap.c
+++ b/src/backend/utils/cache/relfilenodemap.c
@@ -82,7 +82,7 @@ RelfilenodeMapInvalidateCallback(Datum arg, Oid relid)
 }
 
 /*
- * RelfilenodeMapInvalidateCallback
+ * InitializeRelfilenodeMap
  *		Initialize cache, either on first use or after a reset.
  */
 static void
#9Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Masahiro Ikeda (#8)
Re: change a function name in a comment correctly

On 2020/07/07 11:50, Masahiro Ikeda wrote:

Hi,

There is the comment which related function name is not same.
I attached the patch to fix it. Please review.

Thanks for the report and patch! LGTM.
I will commit this later.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

#10Masahiro Ikeda
ikedamsh@oss.nttdata.com
In reply to: Fujii Masao (#9)
Re: change a function name in a comment correctly

There is the comment which related function name is not same.
I attached the patch to fix it. Please review.

Thanks for the report and patch! LGTM.
I will commit this later.

Thanks for checking.

Regards,
--
Masahiro Ikeda
NTT DATA CORPORATION

#11Fujii Masao
masao.fujii@oss.nttdata.com
In reply to: Masahiro Ikeda (#10)
Re: change a function name in a comment correctly

On 2020/07/08 8:12, Masahiro Ikeda wrote:

There is the comment which related function name is not same.
I attached the patch to fix it. Please review.

Thanks for the report and patch! LGTM.
I will commit this later.

Pushed. Thanks!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION