From: Jim Nasby <Jim.Nasby@BlueTreble.com>
To: Kevin Grittner <kgrittn@ymail.com>
To: Merlin Moncure <mmoncure@gmail.com>
To: Greg Stark <stark@mit.edu>
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 18:28:33 -0600
Message-ID: <54A1F1B1.40002@BlueTreble.com> (raw)
In-Reply-To: <1511100927.1386218.1419872004754.JavaMail.yahoo@jws100113.mail.ne1.yahoo.com>
References: <CAHyXU0wa7JOY_eAT90cD8K==NEiaKcLzSthAAms+y95=2S0oJA@mail.gmail.com>
<1511100927.1386218.1419872004754.JavaMail.yahoo@jws100113.mail.ne1.yahoo.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 12/29/14, 10:53 AM, Kevin Grittner wrote:
> Merlin Moncure <mmoncure@gmail.com> wrote:
>
>> Serialization errors only exist as a concession to concurrency
>> and performance. Again, they should be returned as sparsely as
>> possible because they provide absolutely (as Tom pointed
>> out) zero detail to the application.
>
> That is false. They provide an *extremely* valuable piece of
> information which is not currently available when you get a
> duplicate key error -- whether the error occurred because of a race
> condition and will not fail for the same cause if retried.
As for missing details like the duplicated key value, is there a reasonable way to add that as an errdetail() to a serialization failure error?
We do still have to be careful here though; you could still have code using our documented upsert methodology inside a serialized transaction. For example, via a 3rd party extension that can't assume you're using serialized transactions. Would it still be OK to treat that as a serialization failure and bubble that all the way back to the application?
As part of this, we should probably modify our upsert example so it takes transaction_isolation into account...
> As for the fact that RI violations also don't return a
> serialization failure when caused by a race with concurrent
> transactions, I view that as another weakness in PostgreSQL. I
> don't think there is a problem curing one without curing the other
> at the same time. I have known of people writing their own
> triggers to enforce RI rather than defining FKs precisely so that
> they can get a serialization failure return code and do automatic
> retry if it is caused by a race condition. That's less practical
> to compensate for when it comes to unique indexes or constraints.
Wow, that's horrible. :(
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
--
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: Jim.Nasby@BlueTreble.com, kgrittn@ymail.com, mmoncure@gmail.com, stark@mit.edu, 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: <54A1F1B1.40002@BlueTreble.com>
References: <CAHyXU0wa7JOY_eAT90cD8K==NEiaKcLzSthAAms+y95=2S0oJA@mail.gmail.com> <1511100927.1386218.1419872004754.JavaMail.yahoo@jws100113.mail.ne1.yahoo.com> <54A1F1B1.40002@BlueTreble.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