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 14:03:28 +0000 (UTC)
Message-ID: <1956080374.1363800.1419861808211.JavaMail.yahoo@jws100109.mail.ne1.yahoo.com> (raw)
In-Reply-To: <CAHyXU0zjQAB5pNgZ3y=1wpWJtttw3g3XCPYHwCBWVgjBOuUyUw@mail.gmail.com>
References: <CAHyXU0zjQAB5pNgZ3y=1wpWJtttw3g3XCPYHwCBWVgjBOuUyUw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Merlin Moncure <mmoncure@gmail.com> wrote:
> On Fri, Dec 26, 2014 at 12:38 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
>> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>>> Just for starters, a 40XXX error report will fail to provide the
>>> duplicated key's value. This will be a functional regression,
>>
>> Not if, as is normally the case, the transaction is retried from
>> the beginning on a serialization failure. Either the code will
>> check for a duplicate (as in the case of the OP on this thread) and
>> they won't see the error, *or* the the transaction which created
>> the duplicate key will have committed before the start of the retry
>> and you will get the duplicate key error.
>
> I'm not buying that; that argument assumes duplicate key errors are
> always 'upsert' driven. Although OP's code may have checked for
> duplicates it's perfectly reasonable (and in many cases preferable) to
> force the transaction to fail and report the error directly back to
> the application. The application will then switch on the error code
> and decide what to do: retry for deadlock/serialization or abort for
> data integrity error. IOW, the error handling semantics are
> fundamentally different and should not be mixed.
I think you might be agreeing with me without realizing it. Right
now you get "duplicate key error" even if the duplication is caused
by a concurrent transaction -- it is not possible to check the
error code (well, SQLSTATE, technically) to determine whether this
is fundamentally a serialization problem. What we're talking about
is returning the serialization failure return code for the cases
where it is a concurrent transaction causing the failure and
continuing to return the duplicate key error for all other cases.
Either I'm not understanding what you wrote above, or you seem to
be arguing for being able to distinguish between errors caused by
concurrent transactions and those which aren't.
--
Kevin GrittnerEDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
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: <1956080374.1363800.1419861808211.JavaMail.yahoo@jws100109.mail.ne1.yahoo.com>
References: <CAHyXU0zjQAB5pNgZ3y=1wpWJtttw3g3XCPYHwCBWVgjBOuUyUw@mail.gmail.com> <1956080374.1363800.1419861808211.JavaMail.yahoo@jws100109.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