From: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com> |
---|---|
To: | Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | shveta malik <shveta(dot)malik(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | RE: Conflict detection for update_deleted in logical replication |
Date: | 2025-07-01 10:09:35 |
Message-ID: | OS0PR01MB571671E00911EB7BE34C0D8D9441A@OS0PR01MB5716.jpnprd01.prod.outlook.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 1, 2025 at 5:07 PM Dilip Kumar wrote:
>
> On Tue, Jul 1, 2025 at 2:24 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > On Tue, Jul 1, 2025 at 10:53 AM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
> > >
> > > On Tue, Jul 1, 2025 at 10:31 AM Dilip Kumar <dilipbalaut(at)gmail(dot)com>
> wrote:
> > > >
> > > > On Mon, Jun 30, 2025 at 6:59 PM Zhijie Hou (Fujitsu)
> > > > <houzj(dot)fnst(at)fujitsu(dot)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.
Thanks for the comments! I also agree that the barrier is needed.
Here is V45 patch set.
I modified 0001, added write barriers, and improved some comments.
Best Regards,
Hou zj
Attachment | Content-Type | Size |
---|---|---|
v45-0005-Allow-altering-retain_conflict_info-for-enabled-.patch | application/octet-stream | 32.7 KB |
v45-0001-Preserve-conflict-relevant-data-during-logical-r.patch | application/octet-stream | 173.6 KB |
v45-0002-Introduce-a-new-GUC-max_conflict_retention_durat.patch | application/octet-stream | 31.0 KB |
v45-0003-Re-create-the-replication-slot-if-the-conflict-r.patch | application/octet-stream | 7.0 KB |
v45-0004-Support-the-conflict-detection-for-update_delete.patch | application/octet-stream | 30.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2025-07-01 10:28:48 | Re: confusing message in check_tuple |
Previous Message | shveta malik | 2025-07-01 09:50:14 | Re: Logical Replication of sequences |