Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5db2-00063B-Du for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2014 16:55:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5db1-0004xQ-0m for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2014 16:55:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5cZ4-0006rZ-BJ for pgsql-hackers@postgresql.org; Mon, 29 Dec 2014 15:49:02 +0000 Received: from mail-ig0-x233.google.com ([2607:f8b0:4001:c05::233]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Y5cYz-0005Dm-PD for pgsql-hackers@postgresql.org; Mon, 29 Dec 2014 15:49:01 +0000 Received: by mail-ig0-f179.google.com with SMTP id r2so11448714igi.12 for ; Mon, 29 Dec 2014 07:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=+PcQIB8nKhJ9zn7jB/acnfKYDMb3B2EglBdytz2uWMc=; b=WvXABguJyApuiTYfU2Ofx39INarH5pr2TuurZZfbMlf3ai2YxcaMRpdEQMuQmkjrhs yGHAwDS0hKl3yTogfIgSx+5eKVifHLdEi2hZlPTseFKVdDQqT/l26S7W51AkoqgO8Eqr TnVM52x0zQrdPgXrs4R7HMJHOB+tiNN93jIbWtx6RCshY2AWOepOX0zjIAy4BfDkyWDU sJBnJjVRvOiDBLbKvsbY4g1c/c8HmtY+HmTF+MjHbCKpYJ+cjAp6GxdYDqaeKGVLDJ3W gwnBND/eDSdr87bmKUC8tbTQbjqgUJIJ/st/CKV+QWj24Gi/5iKSzkhIfoJQAU2SxPpO jfFg== MIME-Version: 1.0 X-Received: by 10.107.40.16 with SMTP id o16mr32817103ioo.26.1419868133373; Mon, 29 Dec 2014 07:48:53 -0800 (PST) Received: by 10.42.24.65 with HTTP; Mon, 29 Dec 2014 07:48:53 -0800 (PST) In-Reply-To: References: <534827646.1373406.1419865749409.JavaMail.yahoo@jws100110.mail.ne1.yahoo.com> Date: Mon, 29 Dec 2014 18:48:53 +0300 X-Google-Sender-Auth: UAa0TbR8ZQk1_khgB20oGVzAuxE Message-ID: Subject: Re: BUG #12330: ACID is broken for unique constraints From: Nikita Volkov To: Merlin Moncure Cc: Kevin Grittner , Tom Lane , Josh Berkus , "pgsql-hackers@postgresql.org" Content-Type: multipart/alternative; boundary=001a1141d896b7cc51050b5ccf6f X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --001a1141d896b7cc51050b5ccf6f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I believe, the objections expressed in this thread miss a very important point of all this: the isolation property (the "I" in ACID) is violated. Here=E2=80=99s a quote from the Wikipedia article on ACID : The isolation property ensures that the concurrent execution of transactions results in a system state that would be obtained if transactions were executed serially, i.e., one after the other. The original example proves that it's violated. Such behaviour can neither be expected by a user, nor is even mentioned anywhere. Instead in the first paragraph of the =E2=80=9CAbout=E2=80=9D section of the Postgres site it states: It is fully ACID compliant Which is basically just a lie, until issues like this one get dealt with. =E2=80=8B 2014-12-29 18:31 GMT+03:00 Merlin Moncure : > On Mon, Dec 29, 2014 at 9:09 AM, Kevin Grittner wrote= : > > Merlin Moncure wrote: > >> 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 > > > > 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. > > In that case: we don't agree. How come duplicate key errors would be > reported as serialization failures but not RI errors (for example, > inserting a record pointing to another record which a concurrent > transaction deleted)? > > IMO, serialization errors are an implementation artifact and should > not mask well defined errors in SQL under any circumstances (or if > they must, those cases should absolutely be as narrow as possible). > > merlin > --001a1141d896b7cc51050b5ccf6f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

I believe, the objections expressed in = this thread miss a very important point of all this: the isolation property= (the "I" in ACID) is violated.

Here=E2=80=99s a quote from the Wikipedia article on ACID:

The isolation property e=
nsures that the concurrent execution of transactions results in a system st=
ate that would be obtained if transactions were executed serially, i.e., on=
e after the other.

The original example p= roves that it's violated. Such behaviour can neither be expected by a u= ser, nor is even mentioned anywhere. Instead in the first paragraph of the =E2=80=9CAbout=E2=80=9D sectio= n of the Postgres site it states:

It is fully ACID complia=
nt

Which is basically jus= t a lie, until issues like this one get dealt with.

=E2=80=8B

=
2014-12-29 18:31 GMT+03:00 Merlin Moncure <mmo= ncure@gmail.com>:
On Mon, Dec 29, 2014 at 9:09 AM, Kevin Grittner <kgrittn@ymail.com> wrote:
> Merlin Moncure <mmoncure@gmai= l.com> wrote:
>> In other words, the current behavior is:
>> txn A,B begin
>> txn A inserts
>> txn B inserts over A, locks, waits
>> txn A commits.=C2=A0 B aborts with duplicate key error
>
> What I'm proposing is that for serializabl= e transactions B would
> get a serialization failure; otherwise B would get a duplicate key
> error.=C2=A0 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<= br> > on the retry, since it will be starting after the commit of A.=C2=A0 I= f
> 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.

In that case: we don't agree.=C2=A0 How come duplicate key error= s would be
reported as serialization failures but not RI errors (for example,
inserting a record pointing to another record which a concurrent
transaction deleted)?

IMO, serialization errors are an implementation artifact and should
not mask well defined errors in SQL under any circumstances (or if
they must, those cases should absolutely be as narrow as possible).

merlin

--001a1141d896b7cc51050b5ccf6f--