Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y4VdM-0006pz-D3 for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Dec 2014 14:12:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y4VdL-00036i-Sz for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Dec 2014 14:12:51 +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 1Y3mVt-0002MI-Ea for pgsql-bugs@postgresql.org; Wed, 24 Dec 2014 14:02:09 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y3mVm-00008H-D3 for pgsql-bugs@postgresql.org; Wed, 24 Dec 2014 14:02:08 +0000 MIME-Version: 1.0 Subject: BUG #12330: ACID is broken for unique constraints To: pgsql-bugs@postgresql.org From: nikita.y.volkov@mail.ru Date: Wed, 24 Dec 2014 14:01:53 +0000 Message-ID: <20141224140153.11501.49752@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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