Re: BUG #12330: ACID is broken for unique constraints

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: BUG #12330: ACID is broken for unique constraints
Дата
Msg-id CAM3SWZTosvXwTZ8oZBzi2SfJ4F+YZASGNLyc8mzy=73ccGtikQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #12330: ACID is broken for unique constraints  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
On Fri, Dec 26, 2014 at 7:23 AM, Kevin Grittner <kgrittn@ymail.com> wrote:
> Are there any objections to generating a write conflict instead of
> a duplicate key error if the duplicate key was added by a
> concurrent transaction?  Only for transactions at isolation level
> REPEATABLE READ or higher?

This independently occurred to me as perhaps preferable over a year
ago. The INSERT...ON CONFLICT IGNORE feature that my patch adds will
throw such an error for REPEATABLE READ and higher modes rather than
proceeding on the basis of having ignored something from a concurrent
transaction.

+1 from me for doing this in the master branch, if it isn't too
invasive (I think it might be; where is estate available from to work
with close to duplicate checking for B-Trees?). It only makes sense to
do what you propose if the users expects to check that there is no
duplicate ahead of time, and only ever fail with a serialization
failure (not a duplicate violation) from concurrent conflicts. That is
a bit narrow; the OP can only reasonably expect to not see a duplicate
violation on retry because he happens to be checking...most clients
won't, and will "waste" a retry.

The proposed ON CONFLICT IGNORE feature would do this checking for him
correctly, FWIW, but in typical cases there is no real point in
retrying the xact -- you'll just get another duplicate violation
error.

In any case I think exclusion violations should be covered, too.
-- 
Peter Geoghegan



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nikita Volkov
Дата:
Сообщение: Re: BUG #12330: ACID is broken for unique constraints
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Better way of dealing with pgstat wait timeout during buildfarm runs?