Urgent: Key constraints behaving weirdly - Mailing list pgsql-bugs

From Russell Garrett
Subject Urgent: Key constraints behaving weirdly
Date
Msg-id MKEGJINFADFODDNOKEJCOEGCENAA.rg@tcslon.com
Whole thread Raw
Responses Re: Urgent: Key constraints behaving weirdly  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Your name               : Russ Garrett
Your email address      : russ@last.fm

System Configuration
---------------------
  Architecture (example: Intel Pentium)         : P4 Xeon
  Operating System (example: Linux 2.0.26 ELF)  : Linux 2.4.22 ELF
  PostgreSQL version (example: PostgreSQL-7.4)  : PostgreSQL-7.4
  Compiler used (example:  gcc 2.95.2)          : gcc version 3.2.2 20030222
(Red Hat Linux 3.2.2-5)

Please enter a FULL description of your problem:
------------------------------------------------

Constraints are being weird. The reproduction instructions speak for
themselves.
We're using this on a production database and we're understandably getting a
bit edgy.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

last=> \d profile
...
Indexes:
    "profile_pkey" primary key, btree (id)

last=> \di+ profile_pkey
                       List of relations
 Schema |     Name     | Type  | Owner  | Description |  Table
--------+--------------+-------+--------+-------------+---------
 public | profile_pkey | index | lastfm |             | profile
(1 row)

last=> UPDATE profile SET lastsongtime=now(),  r1=r1+0, r2=r2+0, r3=r3+0,
r4=r4+0, r5=r5+0, scrobcount=scrobcount+1 WHERE id=1017057;
ERROR:  duplicate key violates unique constraint "profile_pkey"

last=> SELECT * FROM profile WHERE id=1017057;
   id    |  user   |  name   | description | songspaminterval |
lastsongtime     | entropy | newbie |        creationdate        | r1 | r2 |
r3 | r4 | r5 | scrobcount | newbielistenas | e1 | e2 | e3 | e4  | e5 |
numdisconnections | totalstreamtime
---------+---------+---------+-------------+------------------+-------------
--------+---------+--------+----------------------------+----+----+----+----
+----+------------+----------------+----+----+----+-----+----+--------------
-----+-----------------
 1017057 | 1017075 | Default |             |               60 | 2003-12-18
04:32:34 |       1 | f      | 2003-12-17 23:57:01.582757 |  0 |  0 |  0 |  0
|  0 |         23 |                |  2 |  0 |  0 | 219 |  0 |
0 |               0
(1 row)

last=>


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

No idea :).

pgsql-bugs by date:

Previous
From: Mark Shewmaker
Date:
Subject: Re: SELECT FOR UPDATE differs inside and outside a pl/pgsql
Next
From: Puneet Paul
Date:
Subject: plpgsql For SQLQuery Loop Flags Error