From: | Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de> |
Subject: | Re: [BUG?] check_exclusion_or_unique_constraint false negative |
Date: | 2025-08-22 15:41:25 |
Message-ID: | CADzfLwUuWmb9EVuQb6QN20cpOHtUm6NxYdq=yvPZF1OVuwq6sg@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Amit, a few more explanations related to your message.
> IIUC, the problem you are worried about can happen with DELETE+INSERT
> in the same transaction on the subscriber, right?
Technically, yes - this can occur during a single UPDATE, as well as a
DELETE followed by an INSERT of the same key within the same
transaction (which is effectively equivalent to an UPDATE). However,
it should NOT occur, because at no point in the timeline does a row
with that key fail to exist; therefore, no scan should return “there
is no such row in the index.”
> If so, this should
> happen with DELETE and INSERT in a separate transaction as well.
Yes, it may happen - and in that case, it is correct. This is because
there is a moment between the DELETE and the INSERT when the row does
not exist. Therefore, it is acceptable for a scan to check the index
at that particular moment and find nothing.
> 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.
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.
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.
From | Date | Subject | |
---|---|---|---|
Next Message | shveta malik | 2025-08-22 15:49:44 | Re: Conflict detection for update_deleted in logical replication |
Previous Message | Álvaro Herrera | 2025-08-22 15:35:20 | Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt |