standby promote: in --dry-run mode, display promote command which will be used

For PostgreSQL 12 and later, explicitly note whether repmgr user has
execution permissions on the pg_promote() function.
This commit is contained in:
Ian Barwick
2020-04-02 12:37:32 +09:00
parent d998cab3d0
commit 447054a630
4 changed files with 46 additions and 2 deletions

View File

@@ -15,8 +15,9 @@
repmgr: consolidate replication connection code (Ian)
repmgr: check permissions for "pg_promote()" and fall back to pg_ctl
if necessary (Ian)
repmgr: accept option -S/--superuser for "node check"; GitHub #612 (Ian)
repmgr: in --dry-run mode, display promote command which will be used (Ian)
repmgr: enable "service_promote_command" in PostgreSQL 12 (Ian)
repmgr: accept option -S/--superuser for "node check"; GitHub #612 (Ian)
5.0 2019-10-15
general: add PostgreSQL 12 support (Ian)

View File

@@ -49,6 +49,14 @@
<title>General improvements</title>
<para>
<itemizedlist>
<listitem>
<para>
<link linkend="repmgr-standby-promote"><command>repmgr standby promote</command></link>:
when executed with <option>--dry-run</option>, the method which would be used to promote the node
will be displayed.
</para>
</listitem>
<listitem>
<para>
<link linkend="repmgr-standby-follow"><command>repmgr standby follow</command></link>:
@@ -67,7 +75,7 @@
<listitem>
<para>
<link linkend="repmgr-node-check"><command>repmgr node check</command></link>:
accept option <option>-S</option>/<option>--superuser</option> GitHub #621.
accept option <option>-S</option>/<option>--superuser</option>. GitHub #621.
</para>
</listitem>
</itemizedlist>

View File

@@ -115,6 +115,10 @@
<function>pg_promote()</function>, &repmgr; will fall back to using &quot;<command>pg_ctl promote</command>&quot;.
</para>
<tip>
<para>
Execute <command>repmgr standby promote</command> with the <option>--dry-run</option>
to check whether the &repmgr; user has permission to execute <function>pg_promote()</function>.
</para>
<para>
If the <literal>repmgr</literal> user is not a superuser, execution permission for this
function can be granted with e.g.:

View File

@@ -2409,6 +2409,37 @@ do_standby_promote(void)
}
}
/*
* In --dry-run mode, note which promotion method will be used.
* For Pg12 and later, check whether pg_promote() can be executed.
*/
if (runtime_options.dry_run == true)
{
if (config_file_options.service_promote_command[0] != '\0')
{
log_info(_("node will be promoted using command defined in \"service_promote_command\""));
log_detail(_("\"service_promote_command\" is \"%s\""),
config_file_options.service_promote_command);
}
else if (PQserverVersion(local_conn) >= 120000)
{
if (can_execute_pg_promote(local_conn) == false)
{
log_info(_("node will be promoted using \"pg_ctl promote\""));
log_detail(_("user \"%s\" does not have permission to execute \"pg_promote()\""),
PQuser(local_conn));
}
else
{
log_info(_("node will be promoted using the \"pg_promote()\" function"));
}
}
else
{
log_info(_("node will be promoted using \"pg_ctl promote\""));
}
}
if (runtime_options.dry_run == true)
{
PQfinish(local_conn);