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

From Dilip Kumar
Subject Re: Conflict detection for update_deleted in logical replication
Date
Msg-id CAFiTN-tpw5a6wCr7QCNwBLKPCqKLwntwjguVsrgxJrcBTuQzJg@mail.gmail.com
Whole thread Raw
In response to Re: Conflict detection for update_deleted in logical replication  (Amit Kapila <amit.kapila16@gmail.com>)
Responses RE: Conflict detection for update_deleted in logical replication
List pgsql-hackers
On Tue, Jul 1, 2025 at 2:24 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Tue, Jul 1, 2025 at 10:53 AM Dilip Kumar <dilipbalaut@gmail.com> wrote:
> >
> > On Tue, Jul 1, 2025 at 10:31 AM Dilip Kumar <dilipbalaut@gmail.com> wrote:
> > >
> > > On Mon, Jun 30, 2025 at 6:59 PM Zhijie Hou (Fujitsu)
> > > <houzj.fnst@fujitsu.com> wrote:
> > > >
> > > > On Mon, Jun 30, 2025 at 7:22 PM Amit Kapila wrote:
> > > > >
> > >
> > > I was looking at 0001, it mostly looks fine to me except this one
> > > case.  So here we need to ensure that commits must be acquired after
> > > marking the flag, don't you think we need to ensure strict statement
> > > ordering using memory barrier, or we think it's not required and if so
> > > why?
> > >
>
> Good point. I also think we need a barrier here, but a write barrier
> should be sufficient as we want ordering of two store operations.

+1

> > > RecordTransactionCommitPrepared()
> > > {
> > > ..
> > > + MyProc->delayChkptFlags |= DELAY_CHKPT_IN_COMMIT;
> > > +
> > > + /*
> > > + * Note it is important to set committs value after marking ourselves as
> > > + * in the commit critical section (DELAY_CHKPT_IN_COMMIT). This is because
> > > + * we want to ensure all transactions that have acquired commit timestamp
> > > + * are finished before we allow the logical replication client to advance
> > > + * its xid which is used to hold back dead rows for conflict detection.
> > > + * See maybe_advance_nonremovable_xid.
> > > + */
> > > + committs = GetCurrentTimestamp();
> > > }
> >
> > I'm unsure whether the function call inherently acts as a memory
> > barrier, preventing the compiler from reordering these operations.
> > This needs to be confirmed.
> >
>
> As per my understanding, function calls won't be a memory barrier. In
> this regard, we need a similar change in RecordTransactionCommit as
> well.

Right, we need this in RecordTransactionCommit() as well.

--
Regards,
Dilip Kumar
Google



pgsql-hackers by date:

Previous
From: Jakub Wartak
Date:
Subject: Re: NUMA shared memory interleaving
Next
From: Peter Eisentraut
Date:
Subject: Re: mention unused_oids script in pg_proc.dat