BUG #17173: Primary Key ignored resulting in duplicate values

Started by PG Bug reporting formover 4 years ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 17173
Logged by: Ketan Dhanjee
Email address: kdhanjee@gmail.com
PostgreSQL version: 11.9
Operating system: CentOS Linux 7
Description:

Dear Sir/Madam,

We have found issues on our database tables with duplicate values for tables
defined with primary keys.

Below please find output from one of our tables with duplicate values on the
primary key:

Table DDL:

CREATE TABLE component.priceupdate
(
id bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1
MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
reference character varying(50) COLLATE pg_catalog."default",
effectivedate timestamp(6) without time zone,
"timestamp" timestamp(6) without time zone,
priceupdatestatus character varying(50) COLLATE pg_catalog."default",
modifieddate timestamp(6) without time zone,
CONSTRAINT priceupdate_pkey PRIMARY KEY (id)
USING INDEX TABLESPACE pgwlicsdb
)
WITH (
OIDS = FALSE
)
TABLESPACE pgwlicsdb;

--------------------------------------------
Select output:

select * from component.priceupdate where id=3001279;

id | reference | effectivedate
| timestamp | priceupdatestatus
| modifieddate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3001279 1250812673793 2021-03-18 00:00:00
2021-04-06 13:19:14.997 Failed 2021-05-23
12:16:49.503
3001279 1250812673793 2021-03-18 00:00:00
2021-04-06 13:19:14.997 Failed 2021-05-23
12:45:09.206

We have other tables that also have duplicates for primary key.

Could you please provide feedback with regards to my query.

Thanks
Ketan

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #17173: Primary Key ignored resulting in duplicate values

On Wed, Sep 1, 2021 at 4:44 AM PG Bug reporting form <noreply@postgresql.org>
wrote:

CONSTRAINT priceupdate_pkey PRIMARY KEY (id)
USING INDEX TABLESPACE pgwlicsdb

We have other tables that also have duplicates for primary key.

Could you please provide feedback with regards to my query.

Remove the duplicates and then reindex the backing unique index.

If the duplicates are being created while running a supported version of
PostgreSQL, and they are all using the same tablespace, consider that it is
good odds whatever filesystem your tablespace is on may have issues. As
you don't seem to be using a supported version you should probably fix that
deficiency first though, and see whether new problematic records get
created in the future.

David J.