standby follow: don't restart server (PostgreSQL 13 and later)

As of PostgreSQL 13, changes to the fundamental replication
configuration can be applied with a simple SIGHUP, no restart
required.

In case the old behaviour is desired, i.e. a full restart to apply
the configuration changes, the new configuration parameter
"standby_follow_restart" can be set. This parameter has no effect
in PostgreSQL 12 and earlier.
This commit is contained in:
Ian Barwick
2020-09-29 16:37:09 +09:00
parent 48f95f9a39
commit 73d2088a85
7 changed files with 58 additions and 5 deletions

View File

@@ -3361,9 +3361,27 @@ do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_n
if (server_up == true)
{
/* no "service_restart_command" defined - stop and start using pg_ctl*/
if (PQserverVersion(primary_conn) >= 130000 && config_file_options.standby_follow_restart == false)
{
/* PostgreSQL 13 and later: we'll send SIGHUP via pg_ctl */
get_server_action(ACTION_RELOAD, server_command, config_file_options.data_directory);
success = local_command(server_command, &output_buf);
if (success == true)
{
goto cleanup;
}
/* In the unlikley event that fails, we'll fall back to a restart */
log_warning(_("unable to reload server configuration"));
}
if (config_file_options.service_restart_command[0] == '\0')
{
/* no "service_restart_command" defined - stop and start using pg_ctl */
action = "stopp"; /* sic */
get_server_action(ACTION_STOP_WAIT, server_command, config_file_options.data_directory);
@@ -3445,6 +3463,7 @@ do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_n
}
}
cleanup:
/*
* If replication slots are in use, and an inactive one for this node
* exists on the former upstream, drop it.