Re: Improve pg_sync_replication_slots() to wait for primary to advance

From: Japin Li <japinli(at)hotmail(dot)com>
To: Ajin Cherian <itsajin(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improve pg_sync_replication_slots() to wait for primary to advance
Date: 2025-12-03 05:05:51
Message-ID: MEAPR01MB30314AE414C23401A233F418B6D9A@MEAPR01MB3031.ausprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 02 Dec 2025 at 19:27, Ajin Cherian <itsajin(at)gmail(dot)com> wrote:
> On Fri, Nov 28, 2025 at 5:03 PM Japin Li <japinli(at)hotmail(dot)com> wrote:
>>
>> 1.
>> Initialize slot_persistence_pending to false (to avoid uninitialized values, or
>> initialize to true by mistaken) in update_and_persist_local_synced_slot(). This
>> aligns with the handling of found_consistent_snapshot and remote_slot_precedes
>> in update_local_synced_slot().
>>
>> diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c
>> index 20eada3393..c55ba11f17 100644
>> --- a/src/backend/replication/logical/slotsync.c
>> +++ b/src/backend/replication/logical/slotsync.c
>> @@ -617,6 +617,9 @@ update_and_persist_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid,
>> bool found_consistent_snapshot = false;
>> bool remote_slot_precedes = false;
>>
>> + if (slot_persistence_pending)
>> + *slot_persistence_pending = false;
>> +
>> /* Slotsync skip stats are handled in function update_local_synced_slot() */
>> (void) update_local_synced_slot(remote_slot, remote_dbid,
>> &found_consistent_snapshot,
>>
>
> I don't understand what the comment is here.

I mean, we should always set the slot_persistence_pending variable to false
immediately when entering the update_and_persist_local_synced_slot() function.

For example:

bool slot_persistence_pending = true;

update_and_persist_local_synced_slot(..., &slot_persistence_pending);

/* Here the slot_persistence_pending is always true, is this expected? */

--
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-12-03 05:08:12 Re: Resetting recovery target parameters in pg_createsubscriber
Previous Message Michael Paquier 2025-12-03 05:00:31 Re: Extended Statistics set/restore/clear functions.