From: | Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, shveta malik <shveta(dot)malik(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>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
Subject: | Re: Conflict detection for update_deleted in logical replication |
Date: | 2025-08-01 11:36:28 |
Message-ID: | CAFiTN-tkAQyrppUrLLy8PP_cqFNn-GM13Qvh_sgoCcXXsXzFMA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Aug 1, 2025 at 4:46 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Fri, Aug 1, 2025 at 4:20 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > On Fri, Aug 1, 2025 at 3:58 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
> > >
> > > 4.
> > > + /*
> > > + * Instead of invoking GetOldestNonRemovableTransactionId() for conflict
> > > + * detection, we use the conflict detection slot.xmin. This value will be
> > > + * greater than or equal to the other threshold and provides a more direct
> > > + * and efficient way to identify recently deleted dead tuples relevant to
> > > + * the conflict detection. The oldest_nonremovable_xid is not used here,
> > > + * as it is maintained only by the leader apply worker and unavailable to
> > > + * table sync and parallel apply workers.
> > > + */
> > > + slot = SearchNamedReplicationSlot(CONFLICT_DETECTION_SLOT, true);
> > >
> > > This comment seems a bit confusing to me, Isn't it actually correct to
> > > just use the "conflict detection slot.xmin" even without any other
> > > reasoning?
> > >
> >
> > But it is *not* wrong to use even GetOldestNonRemovableTransactionId()
> > because it will anyway consider conflict detection slot's xmin.
> > However, the value returned by that function could be much older, so
> > slot's xmin is a better choice. Similarly, it is sufficient to use
> > oldest_nonremovable_xid value of apply worker and ideally would be
> > better than slot's xmin because it could give update_deleted in fewer
> > cases, however, we can't use that because of reasons mentioned in the
> > comments.
Got it. It Makes sense to give other possibility and why we chose slot.xmin
> >
>
> How about something like:
> /*
> * For conflict detection, we use the conflict slot's xmin value instead of
> * invoking GetOldestNonRemovableTransactionId(). The slot.xmin acts as a
> * threshold to identify tuples that were recently deleted. These tuples are
> * not visible to concurrent transactions, but we log an update_deleted conflict
> * if such a tuple matches the remote update being applied.
> *
> * Although GetOldestNonRemovableTransactionId() can return a value older than
> * the slot's xmin, for our current purpose it is acceptable to treat tuples
> * deleted by transactions prior to slot.xmin as update_missing conflicts.
> *
> * Ideally, we would use oldest_nonremovable_xid, which is directly maintained
> * by the leader apply worker. However, this value is not available to table
> * synchronization or parallel apply workers, making slot.xmin a practical
> * alternative in those contexts.
> */
I think this is much better.
--
Regards,
Dilip Kumar
Google
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Bapat | 2025-08-01 11:36:36 | Re: Dropping publication breaks logical replication |
Previous Message | Zhijie Hou (Fujitsu) | 2025-08-01 11:32:34 | RE: Conflict detection for update_deleted in logical replication |