please help me recover from duplicate key in unique index - Mailing list pgsql-general

From Charles Martin
Subject please help me recover from duplicate key in unique index
Date
Msg-id 20000104232841.13281.qmail@web3207.mail.yahoo.com
Whole thread Raw
Responses Re: [GENERAL] please help me recover from duplicate key in unique index  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-general
Please help me recover our database from what I think
is a duplicate key in unique index problem.

We have a table of the following form:

    create table foo (id serial primary key, x
integer)

in our code we had, outside of any BEGIN/COMMIT block:

    insert into foo (x) values (...)

Without the transaction block, I believe we have had
duplicate keys inserted.  I've fixed the bug in the
code, but now I need to fix the database!

When I try to vacuum, I get this:

> vacuum;
NOTICE:  Rel sessions: TID 5/2: OID IS INVALID.
TUPGONE 1.
NOTICE:  Rel sessions: TID 5/6: OID IS INVALID.
TUPGONE 1.
NOTICE:  Rel sessions: TID 13/2: OID IS INVALID.
TUPGONE 1.
NOTICE:  Rel sessions: TID 13/6: OID IS INVALID.
TUPGONE 1.
ERROR:  Cannot insert a duplicate key into a unique
index

When I try to dump it out (to manually repair it), I
get this:

$ pg_dump gtmd000103 > gtmd.1
pqWait() -- connection not open
PQendcopy: resetting connection
SQL query to dump the contents of Table 'content' did
not execute correctly.  After we read all the table
contents from the backend, PQendcopy() failed.
Explanation from backend: 'pqWait() -- connection not
open
'.
The query was: 'COPY "content" TO stdout;
'.

Can anybody help me?  I am desperate.  Thanks.

Charles

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://messenger.yahoo.com

pgsql-general by date:

Previous
From: Jim Mercer
Date:
Subject: backend grows during cursor/select/fetch (memory leak?)
Next
From: Charles Martin
Date:
Subject: please help: system info