Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W1HKk-0004mf-4k for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Jan 2014 15:15:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W1HKi-0007LY-SZ for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Jan 2014 15:15:44 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W1CKt-0007Al-1C for pgsql-bugs@postgresql.org; Thu, 09 Jan 2014 09:55:35 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W1CKp-0006yk-U1 for pgsql-bugs@postgresql.org; Thu, 09 Jan 2014 09:55:34 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W1CKp-0003WX-2M for pgsql-bugs@postgresql.org; Thu, 09 Jan 2014 09:55:31 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1W1CKj-0000cI-KF for pgsql-bugs@postgresql.org; Thu, 09 Jan 2014 09:55:25 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: BUG #8757: Dublicate rows, broken primary key. To: pgsql-bugs@postgresql.org From: dimon99901@mail.ru Message-Id: Date: Thu, 09 Jan 2014 09:55:25 +0000 X-Pg-Spam-Score: -1.9 (-) 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: 8757 Logged by: Dmitry Sarafannikov Email address: dimon99901@mail.ru PostgreSQL version: 9.3.2 Operating system: Debian 7.3 Description: Hi. We have newly migrated from 9.1.10 to 9.3.2 version with pg_upgrade and find where strange behaviour. We have table with 70 rows: =# \d blog.blogs Table "blog.blogs" Column | Type | Modifiers -------------------+-----------------------------+-------------------------------------------------------------- id_blog | bigint | not null default nextval('blog.blogs_id_blog_seq'::regclass) blog_url | character varying(50) | not null ...... ...... Indexes: "pk_blog_blogs" PRIMARY KEY, btree (id_blog) Referenced by: TABLE "blog.blog_contest" CONSTRAINT "fk_blog_blog_contest_blog" FOREIGN KEY (id_blog) REFERENCES blog.blogs(id_blog) TABLE "blog.post_votes" CONSTRAINT "fk_blog_post_votes_blog" FOREIGN KEY (id_blog) REFERENCES blog.blogs(id_blog) TABLE "blog.post_visits" CONSTRAINT "fk_post_last_visits_blog" FOREIGN KEY (id_blog) REFERENCES blog.blogs(id_blog) Strange behaviour observed with row id_blog = 26, blog_url = 'orders'. We have no deletes or insertes, but have intensive updates on this table. And we have intensive inserts in tables blog.post_votes and blog.post_visits. In the random time. We get this error: ERROR: insert or update on table "post_visits" violates foreign key constraint "fk_post_last_visits_blog" Detail: Key (id_blog)=(26) is not present in table "blogs". Context: SQL statement "insert into blog.post_visits (...) and this: ERROR: insert or update on table "post_votes" violates foreign key constraint "fk_blog_post_votes_blog" Detail: Key (id_blog)=(26) is not present in table "blogs". Context: SQL statement "insert into blog.post_votes (...) And we look on the table blog.blogs; select * from blog.blogs where id_blog = 26; no rows. select * from blog.blogs where blog_url = 'orders'; We have 2 same rows (but sometimes 3 rows) with id_blog = 26!!! explain analyze select * from blog.blogs where id_blog = 26; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- Index Scan using pk_blog_blogs on blogs (cost=0.14..8.17 rows=1 width=781) (actual time=0.028..0.042 rows=1 loops=1) Index Cond: (id_blog = 26) Total runtime: 0.093 ms So, primary key have dublicate rows and is broken. Then we drop 3 references from tables blog.blog_contest, blog.post_votes, blog.post_visits. delete from blog.blogs where blog_url = 'orders'; insert into blog.blogs (id_blog, blog_url, ...) values (26, 'orders', ...); Create foreign keys and this ok. Through the several hours this situation repeated. Then repeated again, and again. And then we just drop the 2 of 3 referenses to this tables (in table blog.blog_contes we have no rows, updates, inserts with id_blog = 26). We drop references from tables blog.post_votes and blog.post_visits. And this situation don't repeated along more then 24 hours. This is bug? -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs