v2-0001-clean-up-for-776621a5.patch
application/octet-stream
Filename: v2-0001-clean-up-for-776621a5.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v2-0001
Subject: clean up for 776621a5
| File | + | − |
|---|---|---|
| doc/src/sgml/ref/create_subscription.sgml | 2 | 3 |
| doc/src/sgml/ref/pg_dump.sgml | 1 | 3 |
| src/backend/commands/subscriptioncmds.c | 0 | 8 |
| src/backend/replication/slot.c | 9 | 5 |
From 9828953dc478a2dd4895f3482cb1aafb332b142c Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Wed, 31 Jan 2024 10:53:08 +0800
Subject: [PATCH v2] clean up for 776621a5
1. Improve the documentation in create_subscription.sgml.
2. Remove the spurious blank line in subscriptioncmds.c.
3. Remove the NOTICE section for alter_replication_slot in subscriptioncmds.c.
4. Optimize ReplicationSlotAlter() function to prevent disk flushing when the
slot's data remains unchanged.
---
doc/src/sgml/ref/create_subscription.sgml | 5 ++---
doc/src/sgml/ref/pg_dump.sgml | 4 +---
src/backend/commands/subscriptioncmds.c | 8 --------
src/backend/replication/slot.c | 14 +++++++++-----
4 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml
index ee89ffb1d1..15794731bb 100644
--- a/doc/src/sgml/ref/create_subscription.sgml
+++ b/doc/src/sgml/ref/create_subscription.sgml
@@ -117,9 +117,8 @@ CREATE SUBSCRIPTION <replaceable class="parameter">subscription_name</replaceabl
command should connect to the publisher at all. The default
is <literal>true</literal>. Setting this to
<literal>false</literal> will force the values of
- <literal>create_slot</literal>, <literal>enabled</literal>,
- <literal>copy_data</literal>, and <literal>failover</literal>
- to <literal>false</literal>.
+ <literal>create_slot</literal>, <literal>enabled</literal> and
+ <literal>copy_data</literal> to <literal>false</literal>.
(You cannot combine setting <literal>connect</literal>
to <literal>false</literal> with
setting <literal>create_slot</literal>, <literal>enabled</literal>,
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index f8ae4220e1..0caf56e0e0 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -1591,9 +1591,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
information might have to be changed. If the subscription needs to
be enabled for
<link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>,
- then same needs to be done by executing
- <link linkend="sql-altersubscription-params-set">
- <literal>ALTER SUBSCRIPTION ... SET (failover = true)</literal></link>
+ execute <link linkend="sql-altersubscription-params-set"><literal>ALTER SUBSCRIPTION ... SET (failover = true)</literal></link>
after the slot has been created. It might also be appropriate to
truncate the target tables before initiating a new full table copy. If users
intend to copy initial data during refresh they must create the slot with
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index b647a81fc8..860f091eeb 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -73,7 +73,6 @@
#define SUBOPT_LSN 0x00004000
#define SUBOPT_ORIGIN 0x00008000
-
/* check if the 'val' has 'bits' set */
#define IsSet(val, bits) (((val) & (bits)) == (bits))
@@ -852,9 +851,6 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
(opts.failover || walrcv_server_version(wrconn) >= 170000))
{
walrcv_alter_slot(wrconn, opts.slot_name, opts.failover);
- ereport(NOTICE,
- (errmsg("changed the failover state of replication slot \"%s\" on publisher to %s",
- opts.slot_name, opts.failover ? "true" : "false")));
}
}
PG_FINALLY();
@@ -1547,10 +1543,6 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
PG_TRY();
{
walrcv_alter_slot(wrconn, sub->slotname, opts.failover);
-
- ereport(NOTICE,
- (errmsg("changed the failover state of replication slot \"%s\" on publisher to %s",
- sub->slotname, opts.failover ? "true" : "false")));
}
PG_FINALLY();
{
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 110cb59783..fd4e96c9d6 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -696,12 +696,16 @@ ReplicationSlotAlter(const char *name, bool failover)
errmsg("cannot use %s with a physical replication slot",
"ALTER_REPLICATION_SLOT"));
- SpinLockAcquire(&MyReplicationSlot->mutex);
- MyReplicationSlot->data.failover = failover;
- SpinLockRelease(&MyReplicationSlot->mutex);
+ if (MyReplicationSlot->data.failover != failover)
+ {
+ SpinLockAcquire(&MyReplicationSlot->mutex);
+ MyReplicationSlot->data.failover = failover;
+ SpinLockRelease(&MyReplicationSlot->mutex);
+
+ ReplicationSlotMarkDirty();
+ ReplicationSlotSave();
+ }
- ReplicationSlotMarkDirty();
- ReplicationSlotSave();
ReplicationSlotRelease();
}
--
2.30.0.windows.2