From: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com> |
---|---|
To: | Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
Subject: | RE: Conflict detection for multiple_unique_conflicts in logical replication |
Date: | 2025-03-20 11:53:04 |
Message-ID: | OS3PR01MB5718D28DF5B6EABCE46C66EB94D82@OS3PR01MB5718.jpnprd01.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Mar 20, 2025 at 3:06 PM Nisha Moond wrote:
>
> Attached is v6 patch with above comments addressed.
Thanks updating the patch. I have some comments:
1.
The naming style of variables changed in this function seems a bit Inconsistent
with existing ones, I feel we'd better use similar style, e.g., conflictSlots => conflictslots
I included the suggested changes in 0001.
ReportApplyConflict(EState *estate, ResultRelInfo *relinfo, int elevel,
ConflictType type, TupleTableSlot *searchslot,
- TupleTableSlot *localslot, TupleTableSlot *remoteslot,
- Oid indexoid, TransactionId localxmin,
- RepOriginId localorigin, TimestampTz localts)
+ List *conflictSlots, TupleTableSlot *remoteslot,
+ List *conflictIndexes, List *localxmins,
+ List *localorigins, List *localts)
2.
I modified the documents a bit for consistency. Please see 0001
attachment.
3.
I have been thinking whether the codes in ReportApplyConflict() can be improved
further, e.g., avoid the extra checks in do while().
One idea could be that each caller of
ReportApplyConflict() can always pass a valid list for all
list-parameter(e.g., conflictIndexes, localxmins ...). And for the cases when the
caller could not provide a valid item, it would save an invalid value
in the list and pass it to the function.
In this approach, ReportApplyConflict() seems cleaner. I am sharing a POC diff
(0002) for reference, it can pass regression test, but I have not confirmed
every case yet.
4.
+ origin = list_nth_int(localorigins, conflictNum);
...
+ localts = lappend(localts, DatumGetPointer(Int64GetDatum(committs)));
I personally feel this could be improved, because
1) RepOriginId, being a 16-bit value, is smaller than an int, which might not
cause issues but appears somewhat odd when storing a 32-bit value within it;
2) The approach used to store 'committs' seems inelegant (and I didn't find
precedents).
An alternative approach is to introduce a new structure, ConflictTupleInfo,
containing items like slot, origin, committs, and xmin for list integration.
This way, the code could be simpler, and we can avoid the above coding. Please
see 0003 for reference. (Note that some comments in this patch could be
improved)
Best Regards,
Hou zj
Attachment | Content-Type | Size |
---|---|---|
0001-cosmetic-changes.patch.txt | text/plain | 5.7 KB |
0002-refactor-code.patch.txt | text/plain | 9.0 KB |
0003-add-a-struct.patch.txt | text/plain | 12.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2025-03-20 11:59:29 | Re: Index AM API cleanup |
Previous Message | Amit Kapila | 2025-03-20 11:44:54 | Re: Adding a '--clean-publisher-objects' option to 'pg_createsubscriber' utility. |