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

From shveta malik
Subject Re: Conflict detection for update_deleted in logical replication
Date
Msg-id CAJpy0uDw7SmCN_jOvpNUzo_sE4ZsgpqQ5_vHLjm4aCm10eBApA@mail.gmail.com
Whole thread Raw
In response to RE: Conflict detection for update_deleted in logical replication  ("Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>)
Responses RE: Conflict detection for update_deleted in logical replication
List pgsql-hackers
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.

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;
}

It will be slightly easier to understand.

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.

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.

thanks
Shveta



pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Eager aggregation, take 3
Next
From: Richard Guo
Date:
Subject: Re: Eager aggregation, take 3