summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAmit Kapila2024-02-07 04:34:04 +0000
committerAmit Kapila2024-02-07 04:34:04 +0000
commit22f7e61a63306873211e26c7bac9c68631309aef (patch)
tree554a9d76449e79eee15b158aa2ce3b5be8a7dd66 /src
parentb9d6038d7048ddb837aa1d286fb8f5ca0e9b3a83 (diff)
Clean-ups for 776621a5e4 and 7329240437.
Following are a few clean-ups related to failover option support in slots: 1. Improve the documentation in create_subscription.sgml. 2. Remove the spurious blank line in subscriptioncmds.c. 3. Remove the NOTICE for alter_replication_slot in subscriptioncmds.c as we would sometimes print it even when nothing has changed. One can find the change by enabling log_replication_commands on the publisher. 4. Optimize ReplicationSlotAlter() function to prevent disk flushing when the slot's data remains unchanged. Author: Hou Zhijie Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/OS0PR01MB57164904651FB588A518E98894472@OS0PR01MB5716.jpnprd01.prod.outlook.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/subscriptioncmds.c8
-rw-r--r--src/backend/replication/slot.c14
2 files changed, 9 insertions, 13 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index a400ba0e40c..a05d69922d9 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 110cb59783f..fd4e96c9d69 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();
}