Re: [BUG?] check_exclusion_or_unique_constraint false negative
От | Mihail Nikalayeu |
---|---|
Тема | Re: [BUG?] check_exclusion_or_unique_constraint false negative |
Дата | |
Msg-id | CADzfLwUuWmb9EVuQb6QN20cpOHtUm6NxYdq=yvPZF1OVuwq6sg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [BUG?] check_exclusion_or_unique_constraint false negative (Mihail Nikalayeu <mihailnikalayeu@gmail.com>) |
Список | 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. [0]: https://www.postgresql.org/message-id/flat/CADzfLwWC49oanFSGPTf%3D6FJoTw-kAnpPZV8nVqAyR5KL68LrHQ%40mail.gmail.com#5f6b3be849f8d95c166decfae541df09
В списке pgsql-hackers по дате отправления: