mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Allow walreceiver configuration to change on reload
The parameters primary_conninfo, primary_slot_name and wal_receiver_create_temp_slot can now be changed with a simple "reload" signal, no longer requiring a server restart. This is achieved by signalling the walreceiver process to terminate and having it start again with the new values. Thanks to Andres Freund, Kyotaro Horiguchi, Fujii Masao for discussion. Author: Sergei Kornilov <sk@zsrv.org> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/19513901543181143@sas1-19a94364928d.qloud-c.yandex.net
This commit is contained in:
@ -96,17 +96,51 @@ StartupProcShutdownHandler(SIGNAL_ARGS)
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-read the config file.
|
||||
*
|
||||
* If one of the critical walreceiver options has changed, flag xlog.c
|
||||
* to restart it.
|
||||
*/
|
||||
static void
|
||||
StartupRereadConfig(void)
|
||||
{
|
||||
char *conninfo = pstrdup(PrimaryConnInfo);
|
||||
char *slotname = pstrdup(PrimarySlotName);
|
||||
bool tempSlot = wal_receiver_create_temp_slot;
|
||||
bool conninfoChanged;
|
||||
bool slotnameChanged;
|
||||
bool tempSlotChanged = false;
|
||||
|
||||
ProcessConfigFile(PGC_SIGHUP);
|
||||
|
||||
conninfoChanged = strcmp(conninfo, PrimaryConnInfo) != 0;
|
||||
slotnameChanged = strcmp(slotname, PrimarySlotName) != 0;
|
||||
|
||||
/*
|
||||
* wal_receiver_create_temp_slot is used only when we have no slot
|
||||
* configured. We do not need to track this change if it has no effect.
|
||||
*/
|
||||
if (!slotnameChanged && strcmp(PrimarySlotName, "") == 0)
|
||||
tempSlotChanged = tempSlot != wal_receiver_create_temp_slot;
|
||||
pfree(conninfo);
|
||||
pfree(slotname);
|
||||
|
||||
if (conninfoChanged || slotnameChanged || tempSlotChanged)
|
||||
StartupRequestWalReceiverRestart();
|
||||
}
|
||||
|
||||
/* Handle various signals that might be sent to the startup process */
|
||||
void
|
||||
HandleStartupProcInterrupts(void)
|
||||
{
|
||||
/*
|
||||
* Check if we were requested to re-read config file.
|
||||
* Process any requests or signals received recently.
|
||||
*/
|
||||
if (got_SIGHUP)
|
||||
{
|
||||
got_SIGHUP = false;
|
||||
ProcessConfigFile(PGC_SIGHUP);
|
||||
StartupRereadConfig();
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user