![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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) |
#3
| |||
| |||
|
|
Hmm, what does select oid,xmin,xmax,* where userid=1002024; give? |
#4
| |||
| |||
|
|
Hi Stephan, Thanks for a quick reply. pbs=# SELECT oid,xmin,xmax,* FROM UserBalances WHERE UserID = 1002024; oid | xmin | xmax | userid | balance | reservedbalance | modificationdate ---------+-----------+-----------+---------+----------+-----------------+------------------ 2080463 | 248152344 | 248307452 | 1002024 | 10000.00 | 154.02 | 1068947725 2080463 | 248274508 | 248307402 | 1002024 | 10000.00 | 727.57 | 1068949964 (2 rows) Please let me know if there is anything else that I can test. |
#5
| |||
| |||
|
|
This happen a few time to me too and I solved not running anymore each night a REINDEX on the table. I posted this problem in the past ... Do you scedule reindex on this table very often ? Regards Gaetano Mendola |
#6
| |||
| |||
|
|
Hi Stephan, Thanks for a quick reply. pbs=# SELECT oid,xmin,xmax,* FROM UserBalances WHERE UserID = 1002024; oid | xmin | xmax | userid | balance | reservedbalance | modificationdate ---------+-----------+-----------+---------+----------+-----------------+------------------ 2080463 | 248152344 | 248307452 | 1002024 | 10000.00 | 154.02 | 1068947725 2080463 | 248274508 | 248307402 | 1002024 | 10000.00 | 727.57 | 1068949964 (2 rows) |
#7
| |||
| |||
|
|
No, I have never run REINDEX on any table. However, I have done many VACUUM FULL ANALYZE on the complete database. Yes, once I had this also due to a vacuum: |
#8
| |||
| |||
|
|
On Sun, 16 Nov 2003, Joel Jacobson wrote: oid | xmin | xmax | userid | balance | reservedbalance | modificationdate ---------+-----------+-----------+---------+----------+-----------------+------------------ 2080463 | 248152344 | 248307452 | 1002024 | 10000.00 | 154.02 | 1068947725 2080463 | 248274508 | 248307402 | 1002024 | 10000.00 | 727.57 | 1068949964 (2 rows) Hmm, in this case it looks to me like you literally have two versions of the same row rather than two different rows with duplicate primary key values. |
![]() |
| Thread Tools | |
| Display Modes | |
| |