Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFrC1-00072u-PF for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Jan 2015 21:27:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFrC1-0006fW-1W for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Jan 2015 21:27:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFrC0-0006fQ-7r for pgsql-bugs@postgresql.org; Mon, 26 Jan 2015 21:27:32 +0000 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFrBr-0000cw-S3 for pgsql-bugs@postgresql.org; Mon, 26 Jan 2015 21:27:30 +0000 Received: by mail-pa0-f44.google.com with SMTP id rd3so14144259pab.3 for ; Mon, 26 Jan 2015 13:27:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=engineyard.com; s=google; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=dtDrFQDvzOaEmcJsg7zwseBTTh6gAmpYwdrA7E4k1Z4=; b=SrB02cLpkKrfSams2hgmLJMmxjr4YJY4DKYlK64BUgeesydWcNC446OcuUT7Q8Tcw6 m530RjDg5a+jWTW0wbEeq66LG6EvDaK0RT11wHAT3GGosL6VBlgvbU49x/LTXG1HNpxy 884ItAD0y9oHDQ3KlFbzTA+UzakSydLGxIwSg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-type:content-transfer-encoding :subject:message-id:date:to:mime-version; bh=dtDrFQDvzOaEmcJsg7zwseBTTh6gAmpYwdrA7E4k1Z4=; b=Nz/lxFlKlLK7Yv8zDQj7ksnDE7k4tDhQfxV9zjj1eHvJXYLdtgi3Z21O0dFaDkSQMa S7Ng4wFGFouCT6JnHKQWi+PKX7GL2fZ70pzbX8EsHtsRI/6rzkp/QJgE/fiUAc8S0J3B 0Qd9RoXDIb6zH0/cE/iGdZ5+bm4bwUwZbER2XqIVbjUBBPtMmbmNfYAeCponutPdy6aX GDnoNJWHdz9mSJgF4NciJ65rmAAaX5ytIi0O01BS9vlBj1m4ovXKY/GQMblGyT+2m5/O ccaZXhloRAAEHdvPFNJZKPKTIuh5Ly0WXu+Uqq+lSpYaD2bR/pogEaZcCZgqyriXmng/ WBhA== X-Gm-Message-State: ALoCoQljfj/f5di+A3sYxZQ9CikMTu+ZuSrmTWVmld/mYl5uoDYtwVLdB8km1rywNefa4N5l0+o7 X-Received: by 10.68.246.133 with SMTP id xw5mr22155764pbc.34.1422307642877; Mon, 26 Jan 2015 13:27:22 -0800 (PST) Received: from [192.168.0.38] (75-164-237-249.ptld.qwest.net. [75.164.237.249]) by mx.google.com with ESMTPSA id mu6sm10590908pdb.33.2015.01.26.13.27.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 13:27:21 -0800 (PST) From: Erik Jones Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Duplicate key existant/index visibility bug in 9.3.3 Message-Id: Date: Mon, 26 Jan 2015 13:27:19 -0800 To: pgsql-bugs@postgresql.org Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) X-Mailer: Apple Mail (2.1993) X-Pg-Spam-Score: -2.7 (--) 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 Greetings, Today I had a client report an issue restoring a dump made from their produ= ction db on a testing server wherein there existed two rows for a table wit= h identical primary key values. Upon investigation I found this to be true= , but neither is visible via index usage: (Server version: 9.3.3) db=3D# explain select xmin, xmax, cmin, cmax, ctid, id, created_at from tag= s where id =3D 42982; QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ------------------------------------------------------------------------- Index Scan using groups_pkey on tags (cost=3D0.29..8.31 rows=3D1 width=3D= 34) Index Cond: (id =3D 42982) (2 rows) db=3D# select xmin, xmax, cmin, cmax, ctid, id, created_at from tags where = id =3D 42982; xmin | xmax | cmin | cmax | ctid | id | created_at=20 ------+------+------+------+------+----+------------ (0 rows) db=3D# set enable_bitmapscan =3D off; SET db=3D# set enable_indexscan =3D off; SET db=3D# explain select xmin, xmax, cmin, cmax, ctid, id, created_at from tag= s where id =3D 42982; QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 -------------------------------------------------------- Seq Scan on tags (cost=3D0.00..1541.94 rows=3D1 width=3D34) Filter: (id =3D 42982) (2 rows) db=3D# select xmin, xmax, cmin, cmax, ctid, id, created_at from tags where = id =3D 42982; xmin | xmax | cmin | cmax | ctid | id | created_at=20= =20=20=20=20=20=20=20=20 ---------+---------+------+------+----------+-------+----------------------= ------ 1195647 | 1195647 | 2 | 2 | (677,51) | 42982 | 2015-01-23 00:12:19.4= 98942 1195648 | 1195647 | 1 | 1 | (677,52) | 42982 | 2015-01-23 00:12:19.4= 98942 (2 rows) There are other columns on the table and all values in the two entries are = identical. Note that another table has a column that reference this table'= s primary key via a foreign key and there are multiple referencing rows the= re. The last even has the same xmin as the first above: db=3D# select xmin, xmax, cmin, cmax, ctid, id, created_at, tag_id from tag= ged_items where tag_id =3D 42982 order by xmin::text::bigint desc; xmin | xmax | cmin | cmax | ctid | id | created_at = | tag_id=20 ---------+------+------+------+-----------+--------+-----------------------= -----+-------- 1195647 | 0 | 0 | 0 | (361,52) | 130562 | 2015-01-23 01:14:55.80= 9218 | 42982 1195628 | 0 | 0 | 0 | (360,89) | 130557 | 2015-01-23 01:14:55.39= 1223 | 42982 1195619 | 0 | 0 | 0 | (361,44) | 130548 | 2015-01-23 01:14:55.25= 2926 | 42982 1195575 | 0 | 0 | 0 | (360,72) | 130529 | 2015-01-23 01:14:54.66= 755 | 42982 1195536 | 0 | 0 | 0 | (360,60) | 130505 | 2015-01-23 01:14:53.84= 1223 | 42982 1195528 | 0 | 0 | 0 | (361,22) | 130497 | 2015-01-23 01:14:53.72= 5746 | 42982 1195490 | 0 | 0 | 0 | (361,16) | 130487 | 2015-01-23 01:14:53.21= 153 | 42982 1195489 | 0 | 0 | 0 | (360,50) | 130486 | 2015-01-23 01:14:53.19= 7715 | 42982 1195470 | 0 | 0 | 0 | (361,10) | 130477 | 2015-01-23 01:14:52.89= 6855 | 42982 1195402 | 0 | 0 | 0 | (360,28) | 130444 | 2015-01-23 01:14:52.02= 0715 | 42982 I'm assuming that the fact that the xmin values of the rest of the rows are= from before those in the original table is indicative of update traffic si= nce the original tags row was added and that the source of the problem is p= erhaps an update gone wrong, but let me know if I'm way off there.=20 So, a few questions: 1. Is there an existing bug that's been fixed by 9.3.5 that would account f= or this. I scanned the 9.3.4 and 9.3.5 release notes and while the first f= ix listed in the release notes for 9.3.4 (http://www.postgresql.org/docs/9.= 3/static/release-9-3-4.html) was what gave me the idea to disable index usa= ge to see the rows this server has been up and running as a master since Se= ptember so neither the standby nor the crash recovery setup from that bug's= description applies. 2. Is there any other info that I can dig up that could be helpful here? 3. Would manually deleting one of those rows (likely using the ctid to spec= ify which) be safe and make the remaining one visible? If so, I'm assuming= I should delete the second given the xmin of the first referencing row in = the other table? Note that I've already confirmed that there are no other duplicate rows in = this or other tables, at least with no clausing unique ids, via restore tes= ts on a test server. So, I know I can fix this case with a dump/restore bu= t if I can get away with simply deleting one of the offending tuples that w= ould be ideal (i.e. no downtime for the client). --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs