From: Kevin Grittner <kgrittn@ymail.com>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: nikita.y.volkov@mail.ru <nikita.y.volkov@mail.ru>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: BUG #12330: ACID is broken for unique constraints
Date: Mon, 29 Dec 2014 15:09:09 +0000 (UTC)
Message-ID: <534827646.1373406.1419865749409.JavaMail.yahoo@jws100110.mail.ne1.yahoo.com> (raw)
In-Reply-To: <CAHyXU0zr42rgGuqB6=5fW6TEw8183s89U-2epXJ1Me8WDW=RRw@mail.gmail.com>
References: <CAHyXU0zr42rgGuqB6=5fW6TEw8183s89U-2epXJ1Me8WDW=RRw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Merlin Moncure <mmoncure@gmail.com> wrote:
> Well, I'm arguing that duplicate key errors are not serialization
> failures unless it's likely the insertion would succeed upon a retry;
> a proper insert, not an upsert. If that's the case with what you're
> proposing, then it makes sense to me. But that's not what it sounds
> like...your language suggests AIUI that having the error simply be
> caused by another transaction being concurrent would be sufficient to
> switch to a serialization error (feel free to correct me if I'm
> wrong!).
>
> In other words, the current behavior is:
> txn A,B begin
> txn A inserts
> txn B inserts over A, locks, waits
> txn A commits. B aborts with duplicate key error
>
> Assuming that case is untouched, then we're good! My long winded
> point above is that case must fail with duplicate key error; a
> serialization error is suggesting the transaction should be retried
> and it shouldn't be...it would simply fail a second time.
What I'm proposing is that for serializable transactions B would
get a serialization failure; otherwise B would get a duplicate key
error. If the retry of B looks at something in the database to
determine what it's primary key should be it will get a new value
on the retry, since it will be starting after the commit of A. If
it is using a literal key, not based on something changed by A, it
will get a duplicate key error on the retry, since it will be
starting after the commit of A.
It will either succeed on retry or get an error for a different
reason.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: kgrittn@ymail.com, mmoncure@gmail.com, tgl@sss.pgh.pa.us, josh@agliodbs.com, nikita.y.volkov@mail.ru, pgsql-hackers@postgresql.org
Subject: Re: BUG #12330: ACID is broken for unique constraints
In-Reply-To: <534827646.1373406.1419865749409.JavaMail.yahoo@jws100110.mail.ne1.yahoo.com>
References: <CAHyXU0zr42rgGuqB6=5fW6TEw8183s89U-2epXJ1Me8WDW=RRw@mail.gmail.com> <534827646.1373406.1419865749409.JavaMail.yahoo@jws100110.mail.ne1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox