0003_v9_reload_wal_receiver_create_temp_slot.patch
text/x-diff
Filename: 0003_v9_reload_wal_receiver_create_temp_slot.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
Series: patch v9
| File | + | − |
|---|---|---|
| doc/src/sgml/config.sgml | 5 | 1 |
| src/backend/access/transam/xlog.c | 15 | 4 |
| src/backend/utils/misc/guc.c | 1 | 1 |
| src/backend/utils/misc/postgresql.conf.sample | 0 | 1 |
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index f1d2a77043..eb6b3fb876 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -4170,7 +4170,11 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
Specifies whether a WAL receiver should create a temporary replication
slot on the remote instance when no permanent replication slot to use
has been configured (using <xref linkend="guc-primary-slot-name"/>).
- The default is off. This parameter can only be set at server start.
+ The default is off. This parameter can only be set in the
+ <filename>postgresql.conf</filename> file or on the server command line.
+ </para>
+ <para>
+ The WAL receiver is restarted after an update of <varname>wal_receiver_create_temp_slot</varname>.
</para>
</listitem>
</varlistentry>
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index e1f3e905bb..47d69d92d2 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -12278,8 +12278,10 @@ ProcessStartupSigHup(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);
@@ -12289,10 +12291,17 @@ ProcessStartupSigHup(void)
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) &&
+ if ((conninfoChanged || slotnameChanged || tempSlotChanged) &&
currentSource == XLOG_FROM_STREAM
&& WalRcvRunning())
{
@@ -12300,14 +12309,16 @@ ProcessStartupSigHup(void)
ereport(LOG,
(errmsg("The WAL receiver is going to be shut down due to change of %s",
"primary_conninfo")));
- else if (conninfoChanged && slotnameChanged)
+ else if (conninfoChanged && (slotnameChanged || tempSlotChanged))
ereport(LOG,
(errmsg("The WAL receiver is going to be restarted due to change of %s and %s",
- "primary_conninfo", "primary_slot_name")));
+ "primary_conninfo",
+ slotnameChanged ? "primary_slot_name" : "wal_receiver_create_temp_slot")));
else
ereport(LOG,
(errmsg("The WAL receiver is going to be restarted due to change of %s",
- conninfoChanged ? "primary_conninfo" : "primary_slot_name")));
+ conninfoChanged ? "primary_conninfo"
+ : (slotnameChanged ? "primary_slot_name" : "wal_receiver_create_temp_slot"))));
pendingWalRcvRestart = true;
}
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 8d9bdc0eaf..a3650518c4 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2030,7 +2030,7 @@ static struct config_bool ConfigureNamesBool[] =
},
{
- {"wal_receiver_create_temp_slot", PGC_POSTMASTER, REPLICATION_STANDBY,
+ {"wal_receiver_create_temp_slot", PGC_SIGHUP, REPLICATION_STANDBY,
gettext_noop("Sets whether a WAL receiver should create a temporary replication slot if no permanent slot is configured."),
},
&wal_receiver_create_temp_slot,
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 31096725fd..f01e43b818 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -321,7 +321,6 @@
# -1 allows indefinite delay
#wal_receiver_create_temp_slot = off # Create temp slot if primary_slot_name
# is not set.
- # (change requires restart)
#wal_receiver_status_interval = 10s # send replies at least this often
# 0 disables
#hot_standby_feedback = off # send info from standby to prevent