pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: nikita.y.volkov@mail.ru
To: pgsql-bugs@postgresql.org
Subject: BUG #12330: ACID is broken for unique constraints
Date: Wed, 24 Dec 2014 14:01:53 +0000
Message-ID: <20141224140153.11501.49752@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      12330
Logged by:          Nikita Volkov
Email address:      nikita.y.volkov@mail.ru
PostgreSQL version: 9.2.4
Operating system:   OSX 10.8.2
Description:        

Executing concurrent transactions inserting the same value of a unique key
fails with the "duplicate key" error under code "23505" instead of any of
transaction conflict errors with a "40***" code.

E.g., having the following table:

    CREATE TABLE "song_artist" (
      "song_id" INT8 NOT NULL,
      "artist_id" INT8 NOT NULL,
      PRIMARY KEY ("song_id", "artist_id")
    );

Even trying to protect from this with a select, won't help to get away from
the error, because at the beginning of the transaction the key does not
exist yet.

    BEGIN ISOLATION LEVEL SERIALIZABLE READ WRITE;
      INSERT INTO song_artist (song_id, artist_id)
        SELECT 1, 2
          WHERE NOT EXISTS (SELECT * FROM song_artist WHERE song_id=1 AND
artist_id=2);
    COMMIT;



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (27+ messages)  latest in thread

Message-ID: <20141224140153.11501.49752@wrigleys.postgresql.org>
Permalink:  ../20141224140153.11501.49752@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20141224140153.11501.49752@wrigleys.postgresql.org

 · 

reply

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: nikita.y.volkov@mail.ru
  Subject: Re: BUG #12330: ACID is broken for unique constraints
  In-Reply-To: <20141224140153.11501.49752@wrigleys.postgresql.org>
  References: <20141224140153.11501.49752@wrigleys.postgresql.org>

* 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