Re: Conflict detection for update_deleted in logical replication
Dilip Kumar <dilipbalaut@gmail.com>
On Tue, Jul 1, 2025 at 3:39 PM Zhijie Hou (Fujitsu)
<houzj.fnst@fujitsu.com> wrote:
>
> On Tue, Jul 1, 2025 at 5:07 PM Dilip Kumar wrote:
> >
> > 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.
>
> 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.
Thanks for working on this, I will have a look at it latest by tomorrow.
--
Regards,
Dilip Kumar
Google
Commits
-
Fix intermittent BF failures in 035_conflicts.
- 0f42206531b3 19 (unreleased) landed
-
Resume conflict-relevant data retention automatically.
- 0d48d393d465 19 (unreleased) landed
-
Fix intermittent test failure introduced in 6456c6e2c4.
- 01d793698f59 19 (unreleased) landed
-
Fix Coverity issue reported in commit a850be2fe.
- 5ac3c1ac22cb 19 (unreleased) landed
-
Add test to prevent premature removal of conflict-relevant data.
- 6456c6e2c4ad 19 (unreleased) landed
-
Post-commit review fixes for 228c370868.
- 1f7e9ba3ac4e 19 (unreleased) landed
-
Add max_retention_duration option to subscriptions.
- a850be2fe653 19 (unreleased) landed
-
Detect and report update_deleted conflicts.
- fd5a1a0c3e56 19 (unreleased) landed
-
Preserve conflict-relevant data during logical replication.
- 228c37086855 19 (unreleased) landed
-
Integrate FullTransactionIds deeper into two-phase code
- 62a17a92833d 19 (unreleased) cited
-
Improve checks for GUC recovery_target_timeline
- fd7d7b719137 19 (unreleased) cited
-
Prevent excessive delays before launching new logrep workers.
- fd519419c948 18.0 cited
-
Keep WAL segments by slot's last saved restart LSN
- ca307d5cec90 18.0 cited
-
Rework some code handling pg_subscription data in psql and pg_dump
- 08691ea958c2 18.0 cited
-
Use generateClonedIndexStmt to propagate CREATE INDEX to partitions.
- 68dfecbef210 18.0 cited