Re: Conflict Detection and Resolution

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Jan Wieck <jan(at)wi3ck(dot)info>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Conflict Detection and Resolution
Date: 2024-09-30 06:29:04
Message-ID: CAJpy0uDvB3E3PyQJym9OetqMAMWrpVO3r3Y2t3HZjwbJAfcxoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 30, 2024 at 11:04 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> On Mon, Sep 30, 2024 at 2:27 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
> >
> > On Fri, Sep 27, 2024 at 1:00 PM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> ...
> > >
> > > 13. General - ordering of conflict_type.
> > >
> > > nit - Instead of just some apparent random order, let's put each
> > > insert/update/delete conflict type in alphabetical order, so at least
> > > users can find them where they would expect to find them.
> >
> > This ordering was decided while implementing the 'conflict-detection
> > and logging' patch and thus perhaps should be maintained as same. The
> > ordering is insert, update and delete (different variants of these).
> > Please see a comment on it in [1] (comment #2).
> >
> > [1]:https://www.postgresql.org/message-id/TYAPR01MB569224262F44875973FAF344F5B22%40TYAPR01MB5692.jpnprd01.prod.outlook.com
> >
>
> +1 for order insert/update/delete.
>
> My issue was only about the order *within* each of those variants.
> e.g. I think it should be alphabetical:
>
> CURRENT
> insert_exists
> update_origin_differs
> update_exists
> update_missing
> delete_origin_differs
> delete_missing
>
> SUGGESTED
> insert_exists
> update_exists
> update_missing
> update_origin_differs
> delete_missing
> delete_origin_differs
>

Okay, got it now. I have no strong opinion here. I am okay with both.
But since it was originally added by other thread, so it will be good
to know the respective author's opinion as well.

> >
> > > ~~~
> > >
> > > 14.
> > > 99. General - ordering of conflict_resolver
> > >
> > > nit - ditto. Let's name these in alphabetical order. IMO it makes more
> > > sense than the current random ordering.
> > >
> >
> > I feel ordering of resolvers should be same as that of conflict
> > types, i.e. resolvers of insert variants first, then update variants,
> > then delete variants. But would like to know what others think on
> > this.
> >
>
> Resolvers in v14 were documented in this random order:
> error
> skip
> apply_remote
> keep_local
> apply_or_skip
> apply_or_error
>

Yes, these should be changed.

> Some of these are resolvers for different conflicts. How can you order
> these as "resolvers for insert" followed by "resolvers for update"
> followed by "resolvers for delete" without it all still appearing in
> random order?

I was thinking of ordering them like this:

apply_remote: applicable to insert_exists, update_exists,
update_origin_differ, delete_origin_differ
keep_local: applicable to insert_exists,
update_exists, update_origin_differ, delete_origin_differ
apply_or_skip: applicable to update_missing
apply_or_error : applicable to update_missing
skip: applicable to update_missing and
delete_missing
error: applicable to all.

i.e. in order of how they are applicable to conflict_types starting
from insert_exists till delete_origin_differ (i.e. reading
ConflictTypeResolverMap, from left to right and then top to bottom).
Except I have kept 'error' at the end instead of keeping it after
'keep_local' as the former makes more sense there.

thanks
Shveta

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2024-09-30 06:32:42 RE: Conflict detection for update_deleted in logical replication
Previous Message Michael Paquier 2024-09-30 06:24:04 Re: Normalize queries starting with SET for pg_stat_statements