pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Toby Murray <toby.murray@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Violation of primary key constraint
Date: Thu, 31 Jan 2013 18:43:54 -0500
Message-ID: <8059.1359675834@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJeqKgveXGDDNLo6PEShgf+TrdZ2JOXmjfg91CEE+TPG-963_Q@mail.gmail.com>
References: <CAJeqKgveXGDDNLo6PEShgf+TrdZ2JOXmjfg91CEE+TPG-963_Q@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Toby Murray <toby.murray@gmail.com> writes:
> I just had some interaction with RhodiumToad on IRC about a duplicated
> primary key problem I ran into today. After some poking around he
> suggested that I send this to -bugs since it seems like an interesting
> error.

I poked around in the PK index file (thanks for sending that) and could
not find anything that looks wrong.  There are a lot of duplicate keys
(a few of the keys appear more than a thousand times) but I think this
is just the result of update activity that hasn't been vacuumed away
yet.  I count 181340233 leaf index tuples bearing 168352931 distinct
key values --- that makes for a dead-tuple fraction of 7.7% which is
not quite enough to trigger an autovacuum, so it's not terribly
surprising that the dups are still present.

At this point it seems that it's not the index's fault.  What seems more
likely is that somehow the older heap entry failed to get marked "dead"
after an UPDATE.

> ... Especially the one with the ID
> 26709186 since it hasn't been changed in OpenStreetMap in years so
> there is no reason for it to have been touched in any way since the
> import.

Yeah, it's a bit hard to explain that this way unless there was an
UPDATE that didn't change the timestamp or version.  How sure are you
that the updating process always changes those?

> Here are some queries and their results that RhodiumToad had me run to
> try and track things down:

Could we see the full results of heap_page_items(get_raw_page()) for
each of the pages where any of these tuples live, viz

	11249625
	1501614
	11247884
	1520052
	1520056
	11249780
	1528888
	11249622

			regards, tom lane


-- 
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 (8+ messages)  latest in thread

Message-ID: <8059.1359675834@sss.pgh.pa.us>
Permalink:  ../8059.1359675834@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8059.1359675834@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, toby.murray@gmail.com
  Subject: Re: Violation of primary key constraint
  In-Reply-To: <8059.1359675834@sss.pgh.pa.us>
  References: <CAJeqKgveXGDDNLo6PEShgf+TrdZ2JOXmjfg91CEE+TPG-963_Q@mail.gmail.com> <8059.1359675834@sss.pgh.pa.us>

* 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