RE: Synchronizing slots from primary to standby - Mailing list pgsql-hackers

From Zhijie Hou (Fujitsu)
Subject RE: Synchronizing slots from primary to standby
Date
Msg-id OS0PR01MB5716212E157B1453372E893F9495A@OS0PR01MB5716.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Synchronizing slots from primary to standby  (Peter Smith <smithpb2250@gmail.com>)
Responses Re: Synchronizing slots from primary to standby
List pgsql-hackers
On Thursday, December 21, 2023 12:25 PM Peter Smith <smithpb2250@gmail.com> wrote:
> 
> Here is a minor comment for v51-0001
> 
> ======
> src/backend/replication/slot.c
> 
> 1.
> +void
> +RereadConfigAndReInitSlotList(List **standby_slots) {
> + char    *pre_standby_slot_names;
> +
> + /*
> + * If we are running on a standby, there is no need to reload
> + * standby_slot_names since we do not support syncing slots to
> + cascading
> + * standbys.
> + */
> + if (RecoveryInProgress())
> + {
> + ProcessConfigFile(PGC_SIGHUP);
> + return;
> + }
> +
> + pre_standby_slot_names = pstrdup(standby_slot_names);
> +
> + ProcessConfigFile(PGC_SIGHUP);
> +
> + if (strcmp(pre_standby_slot_names, standby_slot_names) != 0) {
> + list_free(*standby_slots); *standby_slots = GetStandbySlotList(true);
> + }
> +
> + pfree(pre_standby_slot_names);
> +}
> 
> Consider below, which seems a simpler way to do that but with just one return
> point and without duplicating the ProcessConfigFile calls:
> 
> SUGGESTION
> {
> char *pre_standby_slot_names = pstrdup(standby_slot_names);
> 
> ProcessConfigFile(PGC_SIGHUP);
> 
> if (!RecoveryInProgress())
> {
>   if (strcmp(pre_standby_slot_names, standby_slot_names) != 0)
>   {
>     list_free(*standby_slots);
>     *standby_slots = GetStandbySlotList(true);
>   }
> }
> 
> pfree(pre_standby_slot_names);
> }

Thanks for the suggestion. I also thought about this, but I'd like to avoid
allocating/freeing memory for the pre_standby_slot_names if not needed.

Best Regards,
Hou zj



pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: Fixing backslash dot for COPY FROM...CSV
Next
From: Amit Kapila
Date:
Subject: Re: speed up a logical replica setup