RE: Synchronizing slots from primary to standby

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Ajin Cherian <itsajin(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Subject: RE: Synchronizing slots from primary to standby
Date: 2023-12-21 05:59:52
Message-ID: OS0PR01MB5716212E157B1453372E893F9495A@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thursday, December 21, 2023 12:25 PM Peter Smith <smithpb2250(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-12-21 06:16:35 Re: speed up a logical replica setup
Previous Message vignesh C 2023-12-21 05:59:24 Re: Fixing backslash dot for COPY FROM...CSV