RE: Conflict detection for update_deleted in logical replication - Mailing list pgsql-hackers

From Zhijie Hou (Fujitsu)
Subject RE: Conflict detection for update_deleted in logical replication
Date
Msg-id TY4PR01MB1690752B933B4DA48FC4738AA940EA@TY4PR01MB16907.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Conflict detection for update_deleted in logical replication  (shveta malik <shveta.malik@gmail.com>)
List pgsql-hackers
On Tuesday, September 9, 2025 5:17 PM shveta malik <shveta.malik@gmail.com> wrote:
> 
> On Tue, Sep 9, 2025 at 11:47 AM Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
> wrote:
> >
> >
> > Here is V71 patch set which addressed above comments and [1].
> >
> 
> Thank You for the patches. Please find a few comments on 001:
> 
> 1)
> In compute_min_nonremovable_xid, when 'wait_for_xid' is true, we should
> have Assert(!worker->oldest_nonremovable_xid) to ensure it is always Invalid
> if reached here.

Added.

> 
> Or we can rewrite the current if-else-if code logic based on worker's oldest-xid
> as main criteria as that will be NULL in both the blocks:
> 
> if (!TransactionIdIsValid(nonremovable_xid))
> {
>   /* resume case */
>   if(wait_for_xid)
>     set worker's oldest-xid using slot's xmin
>   else
>   /* stop case */
>     return;
> }

I am personally not in favor this style because it adds more conditions, so I
did not change in this version.

> 
> 2)
> In stop_conflict_info_retention(), there may be a case where due to an ongoing
> transaction, it could not update retentionactive to false. But even in such cases,
> the function still sets oldest_nonremovable_xid to Invalid, which seems wrong.
> 
> 3)
> Similar in resume flow, it still sets wait_for_initial_xid=true even when it could
> not update retentionactive=true.

Right, I missed to return when the update fails. Fixed in this version.

> 
> 4)
> resume_conflict_info_retention():
> + /*
> + * Return if the launcher has not initialized oldest_nonremovable_xid.
> + *
> + */
> + if (!TransactionIdIsValid(nonremovable_xid))
> + return;
> 
> I think we should have
> 'Assert(MyLogicalRepWorker->wait_for_initial_xid)' before 'return'
> here.

Added.

Best Regards,
Hou zj

pgsql-hackers by date:

Previous
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: RE: Conflict detection for update_deleted in logical replication
Next
From: Chao Li
Date:
Subject: Re: SQL:2023 JSON simplified accessor support