From 22f7e61a63306873211e26c7bac9c68631309aef Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Wed, 7 Feb 2024 10:04:04 +0530 Subject: 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/514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com Discussion: https://postgr.es/m/OS0PR01MB57164904651FB588A518E98894472@OS0PR01MB5716.jpnprd01.prod.outlook.com --- src/backend/replication/slot.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/backend/replication') 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(); } -- cgit v1.2.3