Duplicate primary key record

From: Joel Jacobson <joel(at)jacobson(dot)be>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Duplicate primary key record
Date: 2003-11-16 03:16:08
Message-ID: 1068952568.3fb6ebf8adbde@mail.jacobson.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Your name : Joel Jacobson
Your email address : joel(at)jacobson(dot)be

System Configuration
---------------------
Architecture (example: Intel Pentium) : Intel(R) Pentium(R) III

Operating System (example: Linux 2.0.26 ELF) : Linux 2.4.21

PostgreSQL version (example: PostgreSQL-7.3.3): PostgreSQL-7.3.3

Compiler used (example: gcc 2.95.2) : gcc version 2.95.4 20011002
(Debian prerelease)

Please enter a FULL description of your problem:
------------------------------------------------
I have simple table with a primary key.
Somehow two records with the SAME primary key has managed to get into the
table.
This should as far as I know be impossible.
I should mention that my Postgres daemon crashed two times today when I was
increasing its memory usage setting.
I guess this could have something to do with the problem.

Table
"public.userbalances"
Column | Type |
Modifiers
------------------+---------------+--------------------------------------------------------------------------------------------------
userid | integer | not null
balance | numeric(12,2) | not null
reservedbalance | numeric(12,2) | not null
modificationdate | integer | not null default (date_part('epoch'::text,
('now'::text)::timestamp(6) with time zone))::integer
Indexes: userbalances_pkey primary key btree (userid)
Foreign Key constraints: $1 FOREIGN KEY (userid) REFERENCES users(userid) ON
UPDATE NO ACTION ON DELETE NO ACTION
Triggers: autostamp

pbs=> select * from userbalances where userid = 1002024;
userid | balance | reservedbalance | modificationdate
---------+----------+-----------------+------------------
1002024 | 10000.00 | 154.02 | 1068947725
1002024 | 10000.00 | 727.57 | 1068949964
(2 rows)

pbs=> UPDATE UserBalances SET Balance = 10000, ReservedBalance=0 where userid =
1002024;
ERROR: Cannot insert a duplicate key into unique index userbalances_pkey

I can't understand how two rows with the same primary key can exist in this
table.

I will keep the table in this state if anyone would like to help debugging
this.

Best regards,

Joel Jacobson <joel(at)jacobson(dot)be>

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-11-16 03:48:08 Re: RC2 will not make check on OSX 10.3
Previous Message Theodore Petrosky 2003-11-16 01:40:39 Re: RC2 will not make check on OSX 10.3