RE: Conflict detection and logging in logical replication

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Jan Wieck <jan(at)wi3ck(dot)info>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Subject: RE: Conflict detection and logging in logical replication
Date: 2024-08-01 03:40:09
Message-ID: OS0PR01MB571629E82AA4BC16AC827FD094B22@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday, July 31, 2024 6:53 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Wed, Jul 31, 2024 at 7:40 AM Zhijie Hou (Fujitsu) <houzj(dot)fnst(at)fujitsu(dot)com>
> wrote:
> >
> > Here is the V8 patch set. It includes the following changes:
> >
>
> A few more comments:
> 1. I think in FindConflictTuple() the patch is locking the tuple so that after
> finding a conflict if there is a concurrent delete, it can retry to find the tuple. If
> there is no concurrent delete then we can successfully report the conflict. Is
> that correct? If so, it is better to explain this somewhere in the comments.
>
> 2.
> * Note that this doesn't lock the values in any way, so it's
> * possible that a conflicting tuple is inserted immediately
> * after this returns. But this can be used for a pre-check
> * before insertion.
> ..
> ExecCheckIndexConstraints()
>
> These comments indicate that this function can be used before inserting the
> tuple, however, this patch uses it after inserting the tuple as well. So, I think the
> comments should be updated accordingly.
>
> 3.
> * For unique indexes, we usually don't want to add info to the IndexInfo for
> * checking uniqueness, since the B-Tree AM handles that directly. However,
> * in the case of speculative insertion, additional support is required.
> ...
> BuildSpeculativeIndexInfo(){...}
>
> This additional support is now required even for logical replication to detect
> conflicts. So the comments atop this function should reflect the same.

Thanks for the comments.

Here is the V9 patch set which addressed above and Shveta's comments.

Best Regards,
Hou zj

Attachment Content-Type Size
v9-0003-Collect-statistics-about-conflicts-in-logical-rep.patch application/octet-stream 23.7 KB
v9-0001-Detect-and-log-conflicts-in-logical-replication.patch application/octet-stream 49.6 KB
v9-0002-Add-a-detect_conflict-option-to-subscriptions.patch application/octet-stream 82.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-08-01 03:41:16 Re: v17 vs v16 performance comparison
Previous Message Zhijie Hou (Fujitsu) 2024-08-01 03:39:56 RE: Conflict detection and logging in logical replication