Re: [BUG?] check_exclusion_or_unique_constraint false negative - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: [BUG?] check_exclusion_or_unique_constraint false negative
Date
Msg-id CAA4eK1LZxzORgAoDhix9MWrOqYOsNZuZLW2sTfGsJFM99yRgrg@mail.gmail.com
Whole thread Raw
In response to Re: [BUG?] check_exclusion_or_unique_constraint false negative  (Mihail Nikalayeu <mihailnikalayeu@gmail.com>)
List pgsql-hackers
On Fri, Aug 22, 2025 at 9:12 PM Mihail Nikalayeu
<mihailnikalayeu@gmail.com> wrote:
>
> > BTW, as the update (or DELETE+INSERT) happens at a later time than the
> > publisher's update/delete, so once we have the last_write_win
> > resolution strategy implemented, it is the subscriber operation that
> > will win. So, the current behavior shouldn't cause any problem.
>
> For the last_write_win and UPDATE vs UPDATE case - yes, probably, but
> only by luck.
>

Why only by luck?

> However, there are many scenarios that cannot be implemented
> correctly, for example:
> * DELETE always wins
> * UPDATE with a higher version (column value) wins
> * first_write_win
> * etc.
>

Then these may not lead to eventual consistency for such cases. So,
not sure one should anyway rely on these.

> Also, the cases from [0] are clearly wrong without any conflict
> resolution. In particular, case 2 - there are no real conflicts at all
> (since different sets of columns are involved), but an incorrect
> result may still be produced.
>

I think this questions whether we consider the SnapshotDirty results
correct or not. The case of logical replication giving wrong results
[0] is the behavior from the beginning of logical replication. Now, I
would like to know the opinion of others who were involved in the
initial commit, so added Peter E. to see what he thinks of the same.
If we don't get the opinion here (say people missed to read because of
an unrelated title) then I suggest you start a separate email thread
to discuss just that case and see what others think.

[0]:
https://www.postgresql.org/message-id/flat/CADzfLwWC49oanFSGPTf%3D6FJoTw-kAnpPZV8nVqAyR5KL68LrHQ%40mail.gmail.com#5f6b3be849f8d95c166decfae541df09

--
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: RE: Conflict detection for update_deleted in logical replication
Next
From: Amit Kapila
Date:
Subject: Re: [BUG?] check_exclusion_or_unique_constraint false negative