Unix Technical Forum

duplicate key violates unique constraint pg_toast_635216540

This is a discussion on duplicate key violates unique constraint pg_toast_635216540 within the pgsql Bugs forums, part of the PostgreSQL category; --> Hi, For the last 6 months or so we've had an intermittent issue while doing a data import with ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 10:18 AM
Paul Laughlin
 
Posts: n/a
Default duplicate key violates unique constraint pg_toast_635216540

Hi,

For the last 6 months or so we've had an intermittent issue while doing a
data import with a simple update statement. The fix that we've found for
this issue is to REINDEX TABLE <tablename>;


Has anyone seen this error before?

Again, the error is: duplicate key violates unique constraint pg_toast_<>

Thanks,

Paul

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 10:18 AM
Tom Lane
 
Posts: n/a
Default Re: duplicate key violates unique constraint pg_toast_635216540

"Paul Laughlin" <plaughlin@gmail.com> writes:
> For the last 6 months or so we've had an intermittent issue while doing a
> data import with a simple update statement. The fix that we've found for
> this issue is to REINDEX TABLE <tablename>;


What PG version is this?

Are you sure that the REINDEX actually does anything, as opposed to
merely retrying the data import? I'm thinking you may be having
problems with OID collisions after OID wraparound, which is something
8.1 should defend against but no earlier version does.

What do you get from
select count(distinct chunk_id) from pg_toast.pg_toast_635216540 ;

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 10:18 AM
Paul Laughlin
 
Posts: n/a
Default Re: duplicate key violates unique constraint pg_toast_635216540

warehouse=# select count(distinct chunk_id) from
pg_toast.pg_toast_635216540;
count
-------
74557
(1 row)

We're on version 8.0.7

On 10/16/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Paul Laughlin" <plaughlin@gmail.com> writes:
> > For the last 6 months or so we've had an intermittent issue while doing

> a
> > data import with a simple update statement. The fix that we've found

> for
> > this issue is to REINDEX TABLE <tablename>;

>
> What PG version is this?
>
> Are you sure that the REINDEX actually does anything, as opposed to
> merely retrying the data import? I'm thinking you may be having
> problems with OID collisions after OID wraparound, which is something
> 8.1 should defend against but no earlier version does.
>
> What do you get from
> select count(distinct chunk_id) from pg_toast.pg_toast_635216540 ;
>
> regards, tom lane
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 10:18 AM
Tom Lane
 
Posts: n/a
Default Re: duplicate key violates unique constraint pg_toast_635216540

"Paul Laughlin" <plaughlin@gmail.com> writes:
> warehouse=# select count(distinct chunk_id) from
> pg_toast.pg_toast_635216540;
> count
> -------
> 74557
> (1 row)


> We're on version 8.0.7


Well, 8.0 is definitely at risk for OID collisions in a toast table,
but with so few entries I'd have thought the probability pretty low.
How often do you see these errors?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 10:18 AM
Paul Laughlin
 
Posts: n/a
Default Re: duplicate key violates unique constraint pg_toast_635216540

We got it early last week and again this morning. Before these two it was
about six months ago.

On 10/16/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Paul Laughlin" <plaughlin@gmail.com> writes:
> > warehouse=# select count(distinct chunk_id) from
> > pg_toast.pg_toast_635216540;
> > count
> > -------
> > 74557
> > (1 row)

>
> > We're on version 8.0.7

>
> Well, 8.0 is definitely at risk for OID collisions in a toast table,
> but with so few entries I'd have thought the probability pretty low.
> How often do you see these errors?
>
> regards, tom lane
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-10-2008, 10:18 AM
Tom Lane
 
Posts: n/a
Default Re: duplicate key violates unique constraint pg_toast_635216540

"Paul Laughlin" <plaughlin@gmail.com> writes:
> We got it early last week and again this morning. Before these two it was
> about six months ago.


A certain amount of clustering could be expected, if a lot of the
entries were made at the time of initial table load --- they'd have
nearby OIDs. You can either ignore it (I doubt you need REINDEX, just
retry the update) or else update to PG 8.1 ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:54 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com