Re: Synchronizing slots from primary to standby

From: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(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-11-08 14:39:16
Message-ID: 6d024b88-c3b6-4c7d-bb21-da1aa10cb81f@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 11/8/23 12:50 PM, shveta malik wrote:
> On Wed, Nov 8, 2023 at 3:19 PM Drouvot, Bertrand
> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>>
>> Hi,
>>
>> On 11/8/23 9:57 AM, Amit Kapila wrote:
>>> On Wed, Nov 8, 2023 at 12:32 PM Drouvot, Bertrand
>>> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> On 11/8/23 4:50 AM, Amit Kapila wrote:
>>>>
>>>>> I think if we want to follow
>>>>> this approach then we need to also monitor these slots for any change
>>>>> in the consecutive cycles and if we are able to sync them then
>>>>> accordingly we enable them to use after failover.
>>>>
>>>> What about to add a new field in ReplicationSlotPersistentData
>>>> indicating that we are waiting for "sync" and drop such slots during promotion and
>>>> /or if not in recovery?
>>>>
>>>
>>> This patch is already adding 'synced' flag in
>>> ReplicationSlotPersistentData to distinguish synced slots so that we
>>> can disallow decoding on then in standby and disallow to drop those. I
>>> suggest we change that field to have multiple states where one of the
>>> states would indicate that the initial sync of the slot is done.
>>>
>>
>> Yeah, agree.
>>
>
> I am working on this implementation.

Thanks!

> This sync-state is even needed
> for cascading standbys to know when to start syncing the slots from
> the first standby. It should start syncing only after the first
> standby has finished initialization of it (i.e. wait for primary is
> over) and not before that.
>

Yeah, makes sense.

> Unrelated to above, if there is a user slot on standby with the same
> name which the slot-sync worker is trying to create, then shall it
> emit a warning and skip the sync of that slot or shall it throw an
> error?
>

I'd vote for emit a warning and move on to the next slot if any.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-11-08 14:47:08 Re: Remove MSVC scripts from the tree
Previous Message Aleksander Alekseev 2023-11-08 14:17:26 Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)