BUG #2379: Duplicate pkeys in table - Mailing list pgsql-bugs

From Philip Warner
Subject BUG #2379: Duplicate pkeys in table
Date
Msg-id 200604060629.k366TTYv083632@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #2379: Duplicate pkeys in table  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2379
Logged by:          Philip Warner
Email address:      pjw@rhyme.com.au
PostgreSQL version: 8.0.7
Operating system:   FreeBSD
Description:        Duplicate pkeys in table
Details:

We have an intermittent bug that occurs on a table which is updated several
times per second. The bug occurs every few days/weeks. It is usually
preceeded by a "tuple concurrently updated" messages, but I could not swear
it is always preceeded by it.

The result of the bug is demonstrated by:

select id,count(*) from xxx group by id having count(*)>1;
  id   | count
-------+-------
 24613 |     6
(1 row)

(where ID is the pkey (and xxx is not the real table name)).

The row concerned is one of the most frequestly updated rows, and shows only
one row when I do a 'select * from xxx where id = 24613'.

If I do a select id from xxx order by id, I get 6 duplicate rows.

We have tried a reindex:

mail=# reindex table xxx;
ERROR:  could not create unique index
DETAIL:  Table contains duplicated values.

All of which seems to suggest that there really are 6 data rows with the
same pkey.

None of our code changes the pkey, but we do have several places that update
this table intriggers.

Any help or suggestions would be greatly appreciated.

pgsql-bugs by date:

Previous
From: "Qingqing Zhou"
Date:
Subject: Re: BUG #2371: database crashes with semctl failed error
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #2379: Duplicate pkeys in table