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

From Amit Kapila
Subject Re: Synchronizing slots from primary to standby
Date
Msg-id CAA4eK1+CxDQmUzTVg7Q22C_BxYPrwJ=7GZvdRCrsitJiKTO8=g@mail.gmail.com
Whole thread Raw
In response to Re: Synchronizing slots from primary to standby  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: Synchronizing slots from primary to standby
List pgsql-hackers
On Wed, Mar 6, 2024 at 7:36 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
>
> On Tue, Mar 5, 2024 at 4:21 PM Zhijie Hou (Fujitsu)
> <houzj.fnst@fujitsu.com> wrote:
>
> I have one question about PhysicalWakeupLogicalWalSnd():
>
> +/*
> + * Wake up the logical walsender processes with logical failover slots if the
> + * currently acquired physical slot is specified in standby_slot_names GUC.
> + */
> +void
> +PhysicalWakeupLogicalWalSnd(void)
> +{
> +        List      *standby_slots;
> +
> +        Assert(MyReplicationSlot && SlotIsPhysical(MyReplicationSlot));
> +
> +        standby_slots = GetStandbySlotList();
> +
> +        foreach_ptr(char, name, standby_slots)
> +        {
> +                if (strcmp(name, NameStr(MyReplicationSlot->data.name)) == 0)
> +                {
> +
> ConditionVariableBroadcast(&WalSndCtl->wal_confirm_rcv_cv);
> +                        return;
> +                }
> +        }
> +}
>
> IIUC walsender calls this function every time after updating the
> slot's restart_lsn, which could be very frequently. I'm concerned that
> it could be expensive to do a linear search on the standby_slot_names
> list every time. Is it possible to cache the information in walsender
> local somehow?
>

We can cache this information for WalSender but not for the case where
users use pg_physical_replication_slot_advance(). We don't expect this
list to be long enough to matter, so we can leave this optimization
for the future especially if we encounter any such case unless you
think otherwise.

--
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: "type with xxxx does not exist" when doing ExecMemoize()
Next
From: John Naylor
Date:
Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum