Re: Conflict detection for update_deleted in logical replication

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Conflict detection for update_deleted in logical replication
Date: 2025-08-01 03:44:05
Message-ID: CAJpy0uDNhP+QeH-zGLBgMnRY1JZGVeoZ_dxff5S6HmpnRcWk8A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 31, 2025 at 3:49 PM Zhijie Hou (Fujitsu)
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> On Thursday, July 31, 2025 5:26 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
> >
> > On Tue, Jul 29, 2025 at 10:51 AM Zhijie Hou (Fujitsu) <houzj(dot)fnst(at)fujitsu(dot)com>
> > wrote:
> > >
> > >
> > > This is the V54 patch set, with only patch 0001 updated to address the
> > > latest comments.
> > >
> >
> > Thanks for the patch.
> >
> > While performing tests on the latest patch, I found an assert in tablesync
> > worker in FindDeletedTupleInLocalRel (see
> > Assert(TransactionIdIsValid(oldestxmin))). Logs at [1].
> >
> > It seems table sync worker is trying to apply changes and going to
> > update-deleted conflict detection patch but is not able to find
> > MyLogicalRepWorker->oldest_nonremovable_xid as this xid is set only
> > for apply-worker.
>
> Thanks for reporting. I have fixed it by referring to conflict detection slot's
> xmin instead of the leader worker's oldest_nonremovable_xid. This should
> be safe because the slot.xmin is always valid.
>

Thanks for fixing. In the same context, the comment below still
mentions oldest_nonremovable_xid, it can be corrected.

+  /*
+   * No need to check for a frozen transaction ID, as
+   * TransactionIdPrecedes() manages it internally, treating it as falling
+   * behind the oldest_nonremovable_xid.
+   */

~

Also we may mention 'concurrently deleted' in the comment below as
that makes more sense.

/* The row to be updated was deleted by a different origin */
  CT_UPDATE_DELETED,

~

Apart from these trivial comments changes, patch001 and patch002 look
good to me.

thanks
Shveta

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-08-01 04:01:39 Re: Should --enable-debug set CFLAGS to -O0 instead of -O2?
Previous Message Tom Lane 2025-08-01 03:30:03 Re: Should --enable-debug set CFLAGS to -O0 instead of -O2?