BUG #12330: ACID is broken for unique constraints - Mailing list pgsql-bugs

From nikita.y.volkov@mail.ru
Subject BUG #12330: ACID is broken for unique constraints
Date
Msg-id 20141224140153.11501.49752@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #12330: ACID is broken for unique constraints
Re: BUG #12330: ACID is broken for unique constraints
List pgsql-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;

pgsql-bugs by date:

Previous
From: digoal@126.com
Date:
Subject: BUG #12324: database's age less then max(relAGE) , and stream standby diff with master
Next
From: 284466130@qq.com
Date:
Subject: BUG #12328: can't install the postgresql