Hi On 10/25/2018 09:47 AM, Michael Paquier wrote:
And committed. I double-checked the code, and tweaked a bit the tests so as the test using wait_mode = false is removed as it did not seem worth the extra cycles. I also added a check on the return value of pg_promote when using the wait mode. Another thing was that the function needs to be parallel-restricted.
Documentation for this [*] says "Returns true if promotion is successful and false otherwise", which is not correct if "wait" is false, as it will always return TRUE. [*] https://www.postgresql.org/docs/devel/static/functions-admin.html#FUNCTIONS-RECOVERY-CONTROL Attached patch contains a suggested rewording to clarify this. Regards Ian Barwick -- Ian Barwick http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
commit 208247998484ee70cff5f16050344d53bcc6bb42 Author: Ian Barwick <i...@2ndquadrant.com> Date: Fri Oct 26 11:09:21 2018 +0900 Clarify description of pg_promote function Note that it always returns TRUE if the "wait" parameter is set to false. diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 96d4541..422af61 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -19241,13 +19241,14 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); </entry> <entry><type>boolean</type></entry> <entry> - Promotes a physical standby server. Returns <literal>true</literal> - if promotion is successful and <literal>false</literal> otherwise. - With <parameter>wait</parameter> set to <literal>true</literal>, the - default, the function waits until promotion is completed or - <parameter>wait_seconds</parameter> seconds have passed, otherwise the - function returns immediately after sending the promotion signal to the - postmaster. This function is restricted to superusers by default, but + Promotes a physical standby server. With <parameter>wait</parameter> set + to <literal>true</literal> (the default), the function waits until promotion + is completed or <parameter>wait_seconds</parameter> seconds have passed, + and returns <literal>true</literal> if promotion is successful and + <literal>false</literal> otherwise. If <parameter>wait</parameter> + is set to <literal>false</literal>, the function returns <literal>true</literal> + immediately after sending the promotion signal to the postmaster. + This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function. </entry> </row>