pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
duplicate key value violates unique constraint "pg_class_relname_nsp_index"
42+ messages / 20 participants
[nested] [flat]

* duplicate key value violates unique constraint "pg_class_relname_nsp_index"
@ 2015-05-27 08:19 Mitu Verma <mitu.verma@ericsson.com>
  2015-05-27 08:57 ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Albe Laurenz <laurenz.albe@wien.gv.at>
  2015-05-27 13:05 ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Melvin Davidson <melvin6925@gmail.com>
  0 siblings, 2 replies; 42+ messages in thread

From: Mitu Verma @ 2015-05-27 08:19 UTC (permalink / raw)
  To: pgsql-general

HI,

Following error is continuously seen with the postgreSQL database which we are using at customer site.

Current Errors observed: ./fm_db_VoiceReprocessing1/data/pg_log/postgresql-04.log:2015-04-04 01:00:16 CESTERROR: duplicate key value violates unique constraint "pg_class_relname_nsp_index"


Any pointers on why these errors are coming? What is the meaning of duplicate key value violates unique constraint "pg_class_relname_nsp_index"
If it is due to some index corruption or duplicate index? Please help.


Following tables are used frequently in our case

CREATE TABLE AuditTrailLogEntry
(
event                        int2,
inNodeID                     VARCHAR(80),
inNodeName                   VARCHAR(80),
sourceID                     VARCHAR(300),
inTime                       TIMESTAMP,      -- YYYY/MM/DD HH:MM:SS.mmm
outNodeID                    VARCHAR(80),
outNodeName                  VARCHAR(80),
destinationID                VARCHAR(300),
outTime                      TIMESTAMP,      -- YYYY/MM/DD HH:MM:SS.mmm
bytes                        bigint,
cdrs                         bigint,
tableIndex               bigint,    -- Unique key
noOfSubfilesInFile           bigint,
recordSequenceNumberList     VARCHAR(1000),
primary key             (tableindex)
) TABLESPACE MMDATA; -


CREATE TABLE EventLogEntry
(
tableIndex            int4,   -- Unique key
object                    VARCHAR(80),
method                    VARCHAR(80),
bgwUser                   VARCHAR(80),
time                      CHAR(23),     -- YYYY/MM/DD HH:MM:SS.mmm
realUser                  VARCHAR(80),
host                      VARCHAR(80),
application               VARCHAR(80)
) TABLESPACE MMDATA;


Regards
Mitu

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
  2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
@ 2015-05-27 08:57 ` Albe Laurenz <laurenz.albe@wien.gv.at>
  2015-05-27 09:33   ` Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Pete Hollobon <postgres@hollobon.com>
  1 sibling, 1 reply; 42+ messages in thread

From: Albe Laurenz @ 2015-05-27 08:57 UTC (permalink / raw)
  To: 'Mitu Verma *EXTERN*' <mitu.verma@ericsson.com>; pgsql-general

Mitu Verma wrote:
> Following error is continuously seen with the postgreSQL database which we are using at customer site.
> 
> Current Errors observed: ./fm_db_VoiceReprocessing1/data/pg_log/postgresql-04.log:2015-04-04 01:00:16
> CESTERROR: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
> 
> Any pointers on why these errors are coming? What is the meaning of duplicate key value violates
> unique constraint "pg_class_relname_nsp_index"
> 
> If it is due to some index corruption or duplicate index? Please help.

This is perfectly harmless from a data integrity point of view, it is just an error
message that the user gets when he or she tries to insert a row whose primary key
already exists in the table:

test=> CREATE TABLE test (id integer PRIMARY KEY, val text);
CREATE TABLE
test=> INSERT INTO test VALUES (1, 'one');
INSERT 0 1
test=> INSERT INTO test VALUES (2, 'one');
INSERT 0 1
test=> INSERT INTO test VALUES (1, 'two');
ERROR:  duplicate key value violates unique constraint "test_pkey"
DETAIL:  Key (id)=(1) already exists.

If you don't want user errors to be logged in the server log, you can
increase "log_min_messages" to "log".

Yours,
Laurenz Albe

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
  2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
  2015-05-27 08:57 ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Albe Laurenz <laurenz.albe@wien.gv.at>
@ 2015-05-27 09:33   ` Pete Hollobon <postgres@hollobon.com>
  2015-05-27 09:51     ` Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
  0 siblings, 1 reply; 42+ messages in thread

From: Pete Hollobon @ 2015-05-27 09:33 UTC (permalink / raw)
  To: Albe Laurenz <laurenz.albe@wien.gv.at>; +Cc: Mitu Verma *EXTERN* <mitu.verma@ericsson.com>; pgsql-general

On 27 May 2015 at 09:57, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
>
> Mitu Verma wrote:
> > Following error is continuously seen with the postgreSQL database which
we are using at customer site.
> >
> > Current Errors observed:
./fm_db_VoiceReprocessing1/data/pg_log/postgresql-04.log:2015-04-04 01:00:16
> > CESTERROR: duplicate key value violates unique constraint
"pg_class_relname_nsp_index"
> >
> > Any pointers on why these errors are coming? What is the meaning of
duplicate key value violates
> > unique constraint "pg_class_relname_nsp_index"
> >
> > If it is due to some index corruption or duplicate index? Please help.
>
> This is perfectly harmless from a data integrity point of view, it is
just an error
> message that the user gets when he or she tries to insert a row whose
primary key
> already exists in the table:

But the constraint here is pg_class_relname_nsp_index - the unique index on
pg_class (relname, relnamespace). You don't get that error if you try to
create a table that already exists. How could you end up with that error
(short of attempting to directly insert rows in pg_class)?

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
  2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
  2015-05-27 08:57 ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Albe Laurenz <laurenz.albe@wien.gv.at>
  2015-05-27 09:33   ` Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Pete Hollobon <postgres@hollobon.com>
@ 2015-05-27 09:51     ` Mitu Verma <mitu.verma@ericsson.com>
  2015-05-27 10:07       ` Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Albe Laurenz <laurenz.albe@wien.gv.at>
  0 siblings, 1 reply; 42+ messages in thread

From: Mitu Verma @ 2015-05-27 09:51 UTC (permalink / raw)
  To: Pete Hollobon <postgres@hollobon.com>; Albe Laurenz <laurenz.albe@wien.gv.at>; +Cc: pgsql-general

Hi,

I have tried to see the postgres code(although new to this !) and found this.
declare unique index pg_class_relname_nsp_index 2663 on pg_class using btree(relname name_ops, relnamespace oid_ops)

Not sure why ‘duplicate key value violates unique constraint "pg_class_relname_nsp_index"’ message is coming in the logs ?
Any leads?

Regards
Mitu
From: Pete Hollobon [mailto:postgres@hollobon.com]
Sent: May 27, 2015 3:04 PM
To: Albe Laurenz
Cc: Mitu Verma; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"

On 27 May 2015 at 09:57, Albe Laurenz <laurenz.albe@wien.gv.at<mailto:laurenz.albe@wien.gv.at>> wrote:
>
> Mitu Verma wrote:
> > Following error is continuously seen with the postgreSQL database which we are using at customer site.
> >
> > Current Errors observed: ./fm_db_VoiceReprocessing1/data/pg_log/postgresql-04.log:2015-04-04 01:00:16
> > CESTERROR: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
> >
> > Any pointers on why these errors are coming? What is the meaning of duplicate key value violates
> > unique constraint "pg_class_relname_nsp_index"
> >
> > If it is due to some index corruption or duplicate index? Please help.
>
> This is perfectly harmless from a data integrity point of view, it is just an error
> message that the user gets when he or she tries to insert a row whose primary key
> already exists in the table:

But the constraint here is pg_class_relname_nsp_index - the unique index on pg_class (relname, relnamespace). You don't get that error if you try to create a table that already exists. How could you end up with that error (short of attempting to directly insert rows in pg_class)?


^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
  2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
  2015-05-27 08:57 ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Albe Laurenz <laurenz.albe@wien.gv.at>
  2015-05-27 09:33   ` Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Pete Hollobon <postgres@hollobon.com>
  2015-05-27 09:51     ` Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
@ 2015-05-27 10:07       ` Albe Laurenz <laurenz.albe@wien.gv.at>
  0 siblings, 0 replies; 42+ messages in thread

From: Albe Laurenz @ 2015-05-27 10:07 UTC (permalink / raw)
  To: 'Mitu Verma *EXTERN*' <mitu.verma@ericsson.com>; Pete Hollobon <postgres@hollobon.com>; +Cc: pgsql-general

> From: Pete Hollobon [mailto:postgres@hollobon.com]
> On 27 May 2015 at 09:57, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
>> Mitu Verma wrote:
>>> Following error is continuously seen with the postgreSQL database which we are using at customer site.
>>>
>>> Current Errors observed: ./fm_db_VoiceReprocessing1/data/pg_log/postgresql-04.log:2015-04-04 01:00:16
>>> CESTERROR: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
>>>
>>> Any pointers on why these errors are coming? What is the meaning of duplicate key value violates
>>> unique constraint "pg_class_relname_nsp_index"
>>>
>>> If it is due to some index corruption or duplicate index? Please help.

>> This is perfectly harmless from a data integrity point of view, it is just an error
>> message that the user gets when he or she tries to insert a row whose primary key
>> already exists in the table:

> But the constraint here is pg_class_relname_nsp_index - the unique index on pg_class (relname,
> relnamespace). You don't get that error if you try to create a table that already exists. How could
> you end up with that error (short of attempting to directly insert rows in pg_class)?

Oops, I didn't see that it was a system index.  My mistake.

Mitu Verma wrote:
> I have tried to see the postgres code(although new to this !) and found this.
> 
> declare unique index pg_class_relname_nsp_index 2663 on pg_class using btree(relname name_ops,
> relnamespace oid_ops)
> 
> Not sure why ‘duplicate key value violates unique constraint "pg_class_relname_nsp_index"’ message is
> coming in the logs ?
> 
> Any leads?

Yes, that is could indeed be data corruption, unless somebody messes around with
the system catalogs (can you exclude that?).

I would shut down the cluster right away and take a physical backup of the files
before doing more.

Have there been any crashes lately?

Do you have any idea what action triggers the error message?
	
If you try "REINDEX TABLE pg_class" as superuser, does the problem go away?

Yours,
Laurenz Albe


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
  2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
@ 2015-05-27 13:05 ` Melvin Davidson <melvin6925@gmail.com>
  2015-05-27 13:32   ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 1 reply; 42+ messages in thread

From: Melvin Davidson @ 2015-05-27 13:05 UTC (permalink / raw)
  To: Mitu Verma <mitu.verma@ericsson.com>; +Cc: pgsql-general

What this indicates is that someone, or some thing, is trying to create a
table in a schema that already exists.
Here is the structure of pg_class_relname_nsp_index:
CREATE UNIQUE INDEX pg_class_relname_nsp_index ON pg_class USING btree
(relname, relnamespace)

What you should also see in the error log is a line immediately following
that error which shows you exactly what the conflict is, but you have not
provided that to us.

On Wed, May 27, 2015 at 4:19 AM, Mitu Verma <mitu.verma@ericsson.com> wrote:

>  HI,
>
>
>
> Following error is continuously seen with the postgreSQL database which we
> are using at customer site.
>
>
>
> Current Errors observed:
> ./fm_db_VoiceReprocessing1/data/pg_log/postgresql-04.log:2015-04-04
> 01:00:16 CESTERROR: duplicate key value violates unique constraint
> "pg_class_relname_nsp_index"
>
>
>
>
>
> Any pointers on why these errors are coming? What is the meaning of
> duplicate key value violates unique constraint "pg_class_relname_nsp_index"
>
> If it is due to some index corruption or duplicate index? Please help.
>
>
>
>
>
> Following tables are used frequently in our case
>
>
>
> CREATE TABLE AuditTrailLogEntry
>
> (
>
> event                        int2,
>
> inNodeID                     VARCHAR(80),
>
> inNodeName                   VARCHAR(80),
>
> sourceID                     VARCHAR(300),
>
> inTime                       TIMESTAMP,      -- YYYY/MM/DD HH:MM:SS.mmm
>
> outNodeID                    VARCHAR(80),
>
> outNodeName                  VARCHAR(80),
>
> destinationID                VARCHAR(300),
>
> outTime                      TIMESTAMP,      -- YYYY/MM/DD HH:MM:SS.mmm
>
> bytes                        bigint,
>
> cdrs                         bigint,
>
> tableIndex               bigint,    -- Unique key
>
> noOfSubfilesInFile           bigint,
>
> recordSequenceNumberList     VARCHAR(1000),
>
> primary key             (tableindex)
>
> ) TABLESPACE MMDATA; –
>
>
>
>
>
> CREATE TABLE EventLogEntry
>
> (
>
> tableIndex            int4,   -- Unique key
>
> object                    VARCHAR(80),
>
> method                    VARCHAR(80),
>
> bgwUser                   VARCHAR(80),
>
> time                      CHAR(23),     -- YYYY/MM/DD HH:MM:SS.mmm
>
> realUser                  VARCHAR(80),
>
> host                      VARCHAR(80),
>
> application               VARCHAR(80)
>
> ) TABLESPACE MMDATA;
>
>
>
>
>
> Regards
>
> Mitu
>
>
>



-- 
*Melvin Davidson*
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
  2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
  2015-05-27 13:05 ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Melvin Davidson <melvin6925@gmail.com>
@ 2015-05-27 13:32   ` Adrian Klaver <adrian.klaver@aklaver.com>
  2015-05-27 14:30     ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 42+ messages in thread

From: Adrian Klaver @ 2015-05-27 13:32 UTC (permalink / raw)
  To: Melvin Davidson <melvin6925@gmail.com>; Mitu Verma <mitu.verma@ericsson.com>; +Cc: pgsql-general

On 05/27/2015 06:05 AM, Melvin Davidson wrote:
> What this indicates is that someone, or some thing, is trying to create
> a table in a schema that already exists.

The error you see in that situation is:

postgres-2015-05-27 06:25:10.173 PDT-0ERROR:  relation "table1" already 
exists
postgres-2015-05-27 06:25:10.173 PDT-0STATEMENT:  create table table1 (i 
int);


Best guess is as Pete and Albe said, some user code is directly 
accessing pg_class or the index has been corrupted.

> Here is the structure of pg_class_relname_nsp_index:
> CREATE UNIQUE INDEX pg_class_relname_nsp_index ON pg_class USING btree
> (relname, relnamespace)
>
> What you should also see in the error log is a line immediately
> following that error which shows you exactly what the conflict is, but
> you have not provided that to us.
>



-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
  2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
  2015-05-27 13:05 ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Melvin Davidson <melvin6925@gmail.com>
  2015-05-27 13:32   ` Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" Adrian Klaver <adrian.klaver@aklaver.com>
@ 2015-05-27 14:30     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 42+ messages in thread

From: Tom Lane @ 2015-05-27 14:30 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Melvin Davidson <melvin6925@gmail.com>; Mitu Verma <mitu.verma@ericsson.com>; pgsql-general

Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 05/27/2015 06:05 AM, Melvin Davidson wrote:
>> What this indicates is that someone, or some thing, is trying to create
>> a table in a schema that already exists.

> The error you see in that situation is:

> postgres-2015-05-27 06:25:10.173 PDT-0ERROR:  relation "table1" already 
> exists
> postgres-2015-05-27 06:25:10.173 PDT-0STATEMENT:  create table table1 (i 
> int);

> Best guess is as Pete and Albe said, some user code is directly 
> accessing pg_class or the index has been corrupted.

I don't think it's necessary to make such assumptions to explain the
errors.  What is more likely is that two sessions are trying to create
identically named tables at about the same time.  You do get the nice
user-friendly "already exists" error if the conflicting table was
committed before CREATE TABLE looks --- but in a concurrent-transactions
situation, neither CREATE TABLE will see the other's table as already
existing.  In race conditions like this, it's the unique index on the
catalog that is the duplicate-preventer of last resort, and it's going
to throw this error.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* duplicate key value violates unique constraint and duplicated records
@ 2017-06-29 09:28 Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-29 23:38 ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 01:07 ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  0 siblings, 3 replies; 42+ messages in thread

From: Timokhin Maxim @ 2017-06-29 09:28 UTC (permalink / raw)
  To: pgsql-general

<div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">Hello.</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">We are in process moving to new db from 9.4.8 -&gt; 9.6.3.1. When we did it our application started to throw exception "duplicate key value violates unique constraint" during doing INSERT:</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">INSERT INTO items (ctime, mtime, pubdate, url, title, description, body, status, fulltext_status, orig_id, image_id, video_id, resource_id, priority, checksum) VALUES (%(ctime)s, %(mtime)s, %(pubdate)s, %(url)s, %(title)s, %(description)s, %(body)s, %(status)s, %(fulltext_status)s, %(orig_id)s, %(image_id)s, %(video_id)s, %(resource_id)s, %(priority)s, %(checksum)s) RETURNING items.id'</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">Column url has unique constraint.</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">Also, we saw that during to update value into column status:</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"><div>(psycopg2.IntegrityError) duplicate key value violates unique constraint "items_url"</div><div>    DETAIL:  Key (url)=(<a target="_blank" style="color:rgb(153,0,153);" href="http://www.domainname.ru/ap_module/content/article/400-professional/140-professional/11880">h...;) already exists.</div><div>     [SQL: 'UPDATE items SET status=%(status)s WHERE items.id IN ( ... )...</div><div> </div><div> </div><div>Our table:</div><div> </div></div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"><div>     Column      |            Type             |                             Modifiers</div><div>-----------------+-----------------------------+-------------------------------------------------------------------</div><div> id              | integer                     | not null default nextval(('public.items_id_seq'::text)::regclass)</div><div> ctime           | timestamp without time zone | not null default now()</div><div> pubdate         | timestamp without time zone | not null default now()</div><div> resource_id     | integer                     | not null default 0</div><div> url             | text                        |</div><div> title           | text                        |</div><div> description     | text                        |</div><div> body            | text                        |</div><div> status          | smallint                    | not null default 0</div><div> image           | text                        |</div><div> orig_id         | integer                     | not null default 0</div><div> mtime           | timestamp without time zone | not null default now()</div><div> checksum        | text                        |</div><div> video_url       | text                        |</div><div> audio_url       | text                        |</div><div> content_type    | smallint                    | default 0</div><div> author          | text                        |</div><div> video           | text                        |</div><div> fulltext_status | smallint                    | default 0</div><div> summary         | text                        |</div><div> image_id        | integer                     |</div><div> video_id        | integer                     |</div><div> priority        | smallint                    |</div><div>Indexes:</div><div>    "items_pkey" PRIMARY KEY, btree (id)</div><div>    "items_url" UNIQUE, btree (url)</div><div>    "items_resource_id" btree (resource_id)</div><div>    "ndx__items__ctime" btree (ctime)</div><div>    "ndx__items__image" btree (image_id)</div><div>    "ndx__items__mtime" btree (mtime)</div><div>    "ndx__items__pubdate" btree (pubdate)</div><div>    "ndx__items__video" btree (video_id)</div><div>Foreign-key constraints:</div><div>    "items_fkey1" FOREIGN KEY (image_id) REFERENCES images(id) ON UPDATE CASCADE ON DELETE SET NULL</div><div>    "items_fkey2" FOREIGN KEY (video_id) REFERENCES videos(id) ON UPDATE CASCADE ON DELETE SET NULL</div><div>Referenced by:</div><div>    TABLE "cluster_image" CONSTRAINT "cluster_image_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "cluster_meta" CONSTRAINT "cluster_meta_item_id_fkey" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "events" CONSTRAINT "events_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "item_cluster" CONSTRAINT "item_cluster_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_blogs" CONSTRAINT "items_blogs_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_reflink" CONSTRAINT "items_reflink_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_related" CONSTRAINT "items_related_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_summaries" CONSTRAINT "items_summaries_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "quotations" CONSTRAINT "quotations_fkey3" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "summaries" CONSTRAINT "summaries_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div></div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"><div> </div><div> </div><div>Everything would be not bad if in the table weren't appeared duplicated records in url column.</div><div>Any idea how is it possible? </div><div> </div><div>Thank you!</div></div></div><div> </div><div>-- <br />Timokhin 'maf' Maxim</div><div> </div>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
@ 2017-06-29 21:21 ` Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 09:49   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2 siblings, 2 replies; 42+ messages in thread

From: Melvin Davidson @ 2017-06-29 21:21 UTC (permalink / raw)
  To: Timokhin Maxim <ncx2@yandex.com>; +Cc: pgsql-general

On Thu, Jun 29, 2017 at 5:28 AM, Timokhin Maxim <ncx2@yandex.com> wrote:

> Hello.
> We are in process moving to new db from 9.4.8 -> 9.6.3.1. When we did it
> our application started to throw exception "duplicate key value violates
> unique constraint" during doing INSERT:
>
> INSERT INTO items (ctime, mtime, pubdate, url, title, description, body,
> status, fulltext_status, orig_id, image_id, video_id, resource_id,
> priority, checksum) VALUES (%(ctime)s, %(mtime)s, %(pubdate)s, %(url)s,
> %(title)s, %(description)s, %(body)s, %(status)s, %(fulltext_status)s,
> %(orig_id)s, %(image_id)s, %(video_id)s, %(resource_id)s, %(priority)s,
> %(checksum)s) RETURNING items.id'
>
> Column url has unique constraint.
>
>
> Also, we saw that during to update value into column status:
> (psycopg2.IntegrityError) duplicate key value violates unique constraint
> "items_url"
>     DETAIL:  Key (url)=(http://www.domainname.
> ru/ap_module/content/article/400-professional/140-professional/11880)
> already exists.
>      [SQL: 'UPDATE items SET status=%(status)s WHERE items.id IN ( ...
> )...
>
>
> Our table:
>
>
>      Column      |            Type             |
>   Modifiers
> -----------------+-----------------------------+------------
> -------------------------------------------------------
>  id              | integer                     | not null default
> nextval(('public.items_id_seq'::text)::regclass)
>  ctime           | timestamp without time zone | not null default now()
>  pubdate         | timestamp without time zone | not null default now()
>  resource_id     | integer                     | not null default 0
>  url             | text                        |
>  title           | text                        |
>  description     | text                        |
>  body            | text                        |
>  status          | smallint                    | not null default 0
>  image           | text                        |
>  orig_id         | integer                     | not null default 0
>  mtime           | timestamp without time zone | not null default now()
>  checksum        | text                        |
>  video_url       | text                        |
>  audio_url       | text                        |
>  content_type    | smallint                    | default 0
>  author          | text                        |
>  video           | text                        |
>  fulltext_status | smallint                    | default 0
>  summary         | text                        |
>  image_id        | integer                     |
>  video_id        | integer                     |
>  priority        | smallint                    |
> Indexes:
>     "items_pkey" PRIMARY KEY, btree (id)
>     "items_url" UNIQUE, btree (url)
>     "items_resource_id" btree (resource_id)
>     "ndx__items__ctime" btree (ctime)
>     "ndx__items__image" btree (image_id)
>     "ndx__items__mtime" btree (mtime)
>     "ndx__items__pubdate" btree (pubdate)
>     "ndx__items__video" btree (video_id)
> Foreign-key constraints:
>     "items_fkey1" FOREIGN KEY (image_id) REFERENCES images(id) ON UPDATE
> CASCADE ON DELETE SET NULL
>     "items_fkey2" FOREIGN KEY (video_id) REFERENCES videos(id) ON UPDATE
> CASCADE ON DELETE SET NULL
> Referenced by:
>     TABLE "cluster_image" CONSTRAINT "cluster_image_fkey2" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "cluster_meta" CONSTRAINT "cluster_meta_item_id_fkey" FOREIGN
> KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "events" CONSTRAINT "events_fkey2" FOREIGN KEY (item_id)
> REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "item_cluster" CONSTRAINT "item_cluster_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_blogs" CONSTRAINT "items_blogs_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_reflink" CONSTRAINT "items_reflink_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_related" CONSTRAINT "items_related_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_summaries" CONSTRAINT "items_summaries_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "quotations" CONSTRAINT "quotations_fkey3" FOREIGN KEY (item_id)
> REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "summaries" CONSTRAINT "summaries_fkey2" FOREIGN KEY (item_id)
> REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>
>
> Everything would be not bad if in the table weren't appeared duplicated
> records in url column.
> Any idea how is it possible?
>
> Thank you!
>
> --
> Timokhin 'maf' Maxim
>
>













*It's possible you have index corruption on 9.4.8 version that was not
detected.Try the following query on 9.4.8 to see if any rows are selected.
Then you can decide how to fix from there.SELECT a.id <http://a.id;,
a.url,       b.id <http://b.id;, b.url  FROM items a,       items b WHERE
a.id <http://a.id; <> b.id <http://b.id;   AND a.url = b.url ORDER by a.id
<http://a.id>;*
-- 
*Melvin Davidson*
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
@ 2017-06-30 09:49   ` Timokhin Maxim <ncx2@yandex.com>
  1 sibling, 0 replies; 42+ messages in thread

From: Timokhin Maxim @ 2017-06-30 09:49 UTC (permalink / raw)
  To: Melvin Davidson <melvin6925@gmail.com>; +Cc: pgsql-general

<div>Hello! Yes, it looks like a bug or an index corruption. Now, I'm going to drop an index, find and fix duplicates, and create index again.</div><div>But I would do it on 9.6.3 because there is a great feature ''max_parallel_workers_per_gather" there.</div><div>Well, see what will happen.</div><div> </div><div>-- <br />Пожалуйста!</div><div>Используйте кнопку "ответить всем".</div><div>Не удаляйте историю переписки.</div><div>Спасибо. С уважением, Timokhin 'maf' Maxim</div><div> </div><div> </div><div> </div><div>30.06.2017, 00:22, "Melvin Davidson" &lt;melvin6925@gmail.com&gt;:</div><blockquote type="cite"><div> <div> <div>On Thu, Jun 29, 2017 at 5:28 AM, Timokhin Maxim <span>&lt;<a target="_blank" href="mailto:ncx2@yandex.com">ncx2@yandex.com</a>&gt;</span> wrote:<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">Hello.</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">We are in process moving to new db from 9.4.8 -&gt; 9.6.3.1. When we did it our application started to throw exception "duplicate key value violates unique constraint" during doing INSERT:</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">INSERT INTO items (ctime, mtime, pubdate, url, title, description, body, status, fulltext_status, orig_id, image_id, video_id, resource_id, priority, checksum) VALUES (%(ctime)s, %(mtime)s, %(pubdate)s, %(url)s, %(title)s, %(description)s, %(body)s, %(status)s, %(fulltext_status)s, %(orig_id)s, %(image_id)s, %(video_id)s, %(resource_id)s, %(priority)s, %(checksum)s) RETURNING <a target="_blank" href="http://items.id/">items.id</a>'</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">Column url has unique constraint.</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);">Also, we saw that during to update value into column status:</div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"><div>(psycopg2.IntegrityError) duplicate key value violates unique constraint "items_url"</div><div>    DETAIL:  Key (url)=(<a target="_blank" style="color:rgb(153,0,153);" href="http://www.domainname.ru/ap_module/content/article/400-professional/140-professional/11880">h...;) already exists.</div><div>     [SQL: 'UPDATE items SET status=%(status)s WHERE <a target="_blank" href="http://items.id/">items.id</a; IN ( ... )...</div><div> </div><div> </div><div>Our table:</div><div> </div></div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"> </div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"><div>     Column      |            Type             |                             Modifiers</div><div>-----------------+-----------------------------+-------------------------------------------------------------------</div><div> id              | integer                     | not null default nextval(('public.items_id_seq'::text)::regclass)</div><div> ctime           | timestamp without time zone | not null default now()</div><div> pubdate         | timestamp without time zone | not null default now()</div><div> resource_id     | integer                     | not null default 0</div><div> url             | text                        |</div><div> title           | text                        |</div><div> description     | text                        |</div><div> body            | text                        |</div><div> status          | smallint                    | not null default 0</div><div> image           | text                        |</div><div> orig_id         | integer                     | not null default 0</div><div> mtime           | timestamp without time zone | not null default now()</div><div> checksum        | text                        |</div><div> video_url       | text                        |</div><div> audio_url       | text                        |</div><div> content_type    | smallint                    | default 0</div><div> author          | text                        |</div><div> video           | text                        |</div><div> fulltext_status | smallint                    | default 0</div><div> summary         | text                        |</div><div> image_id        | integer                     |</div><div> video_id        | integer                     |</div><div> priority        | smallint                    |</div><div>Indexes:</div><div>    "items_pkey" PRIMARY KEY, btree (id)</div><div>    "items_url" UNIQUE, btree (url)</div><div>    "items_resource_id" btree (resource_id)</div><div>    "ndx__items__ctime" btree (ctime)</div><div>    "ndx__items__image" btree (image_id)</div><div>    "ndx__items__mtime" btree (mtime)</div><div>    "ndx__items__pubdate" btree (pubdate)</div><div>    "ndx__items__video" btree (video_id)</div><div>Foreign-key constraints:</div><div>    "items_fkey1" FOREIGN KEY (image_id) REFERENCES images(id) ON UPDATE CASCADE ON DELETE SET NULL</div><div>    "items_fkey2" FOREIGN KEY (video_id) REFERENCES videos(id) ON UPDATE CASCADE ON DELETE SET NULL</div><div>Referenced by:</div><div>    TABLE "cluster_image" CONSTRAINT "cluster_image_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "cluster_meta" CONSTRAINT "cluster_meta_item_id_fkey" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "events" CONSTRAINT "events_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "item_cluster" CONSTRAINT "item_cluster_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_blogs" CONSTRAINT "items_blogs_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_reflink" CONSTRAINT "items_reflink_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_related" CONSTRAINT "items_related_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "items_summaries" CONSTRAINT "items_summaries_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "quotations" CONSTRAINT "quotations_fkey3" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div><div>    TABLE "summaries" CONSTRAINT "summaries_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE</div></div><div style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:15px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-transform:none;white-space:normal;background-color:rgb(255,255,255);"><div> </div><div> </div><div>Everything would be not bad if in the table weren't appeared duplicated records in url column.</div><div>Any idea how is it possible? </div><div> </div><div>Thank you!</div></div></div><div><span><font color="#888888"> </font></span></div><div><span><font color="#888888">-- <br />Timokhin 'maf' Maxim</font></span></div><div><span><font color="#888888"> </font></span></div></blockquote></div><br /><strong>It's possible you have index corruption on 9.4.8 version that was not detected.<br /><br />Try the following query on 9.4.8 to see if any rows are selected. Then you can decide<br />how to fix from there.<br /><br />SELECT <a href="http://a.id/">a.id</a;, a.url,<br />       <a href="http://b.id/">b.id</a;, b.url<br />  FROM items a,<br />       items b<br /> WHERE <a href="http://a.id/">a.id</a; &lt;&gt; <a href="http://b.id/">b.id</a><br />   AND a.url = b.url<br /> ORDER by <a href="http://a.id/">a.id</a>;</strong><br /><br />--<div><div><font size="4"><strong><span style="font-family:courier new,monospace;">Melvin Davidson</span></strong></font><br /><font size="3" style="font-weight:bold;"><span style="color:#8000ff;">I reserve the right to fantasize.  Whether or not you </span><br style="color:rgb(128,0,255);" /><span style="color:#8000ff;">wish to share my fantasy is entirely up to you. </span><img style="color:rgb(128,0,255);" src="http://us.i1.yimg.com/us.yimg.com/i/mesg/tsmileys2/01.gif"; /></font></div></div></div></div></blockquote>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
@ 2017-06-30 11:58   ` Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 1 reply; 42+ messages in thread

From: Timokhin Maxim @ 2017-06-30 11:58 UTC (permalink / raw)
  To: Melvin Davidson <melvin6925@gmail.com>; Adrian Klaver <adrian.klaver@aklaver.com>; stevenchang1213@gmail.com; +Cc: pgsql-general

BTW, we are moving using:

pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v —xlog-method=stream —checkpoint=fast

After that we are upping version to 9.6.3.
I've looked through the documentation https://postgrespro.ru/docs/postgrespro/9.6/app-pgbasebackup and didn't find details about how pg_basebackup works with b-tree indexes.
Is it possible that pg_basebackup just copies indexes as is and that is cause of corruption. Or it pass indexes as instruction that says "after upping db make indexes" ? 

Thank you.


-- 
Timokhin 'maf' Maxim



30.06.2017, 00:22, "Melvin Davidson" <melvin6925@gmail.com>:
> On Thu, Jun 29, 2017 at 5:28 AM, Timokhin Maxim <ncx2@yandex.com> wrote:
>> Hello.
>> We are in process moving to new db from 9.4.8 -> 9.6.3.1. When we did it our application started to throw exception "duplicate key value violates unique constraint" during doing INSERT:
>>
>> INSERT INTO items (ctime, mtime, pubdate, url, title, description, body, status, fulltext_status, orig_id, image_id, video_id, resource_id, priority, checksum) VALUES (%(ctime)s, %(mtime)s, %(pubdate)s, %(url)s, %(title)s, %(description)s, %(body)s, %(status)s, %(fulltext_status)s, %(orig_id)s, %(image_id)s, %(video_id)s, %(resource_id)s, %(priority)s, %(checksum)s) RETURNING items.id'
>>
>> Column url has unique constraint.
>>
>> Also, we saw that during to update value into column status:
>> (psycopg2.IntegrityError) duplicate key value violates unique constraint "items_url"
>>     DETAIL:  Key (url)=(http://www.domainname.ru/ap_module/content/article/400-professional/140-professional/11880) already exists.
>>      [SQL: 'UPDATE items SET status=%(status)s WHERE items.id IN ( ... )...
>>
>> Our table:
>>
>>      Column      |            Type             |                             Modifiers
>> -----------------+-----------------------------+-------------------------------------------------------------------
>>  id              | integer                     | not null default nextval(('public.items_id_seq'::text)::regclass)
>>  ctime           | timestamp without time zone | not null default now()
>>  pubdate         | timestamp without time zone | not null default now()
>>  resource_id     | integer                     | not null default 0
>>  url             | text                        |
>>  title           | text                        |
>>  description     | text                        |
>>  body            | text                        |
>>  status          | smallint                    | not null default 0
>>  image           | text                        |
>>  orig_id         | integer                     | not null default 0
>>  mtime           | timestamp without time zone | not null default now()
>>  checksum        | text                        |
>>  video_url       | text                        |
>>  audio_url       | text                        |
>>  content_type    | smallint                    | default 0
>>  author          | text                        |
>>  video           | text                        |
>>  fulltext_status | smallint                    | default 0
>>  summary         | text                        |
>>  image_id        | integer                     |
>>  video_id        | integer                     |
>>  priority        | smallint                    |
>> Indexes:
>>     "items_pkey" PRIMARY KEY, btree (id)
>>     "items_url" UNIQUE, btree (url)
>>     "items_resource_id" btree (resource_id)
>>     "ndx__items__ctime" btree (ctime)
>>     "ndx__items__image" btree (image_id)
>>     "ndx__items__mtime" btree (mtime)
>>     "ndx__items__pubdate" btree (pubdate)
>>     "ndx__items__video" btree (video_id)
>> Foreign-key constraints:
>>     "items_fkey1" FOREIGN KEY (image_id) REFERENCES images(id) ON UPDATE CASCADE ON DELETE SET NULL
>>     "items_fkey2" FOREIGN KEY (video_id) REFERENCES videos(id) ON UPDATE CASCADE ON DELETE SET NULL
>> Referenced by:
>>     TABLE "cluster_image" CONSTRAINT "cluster_image_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "cluster_meta" CONSTRAINT "cluster_meta_item_id_fkey" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "events" CONSTRAINT "events_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "item_cluster" CONSTRAINT "item_cluster_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "items_blogs" CONSTRAINT "items_blogs_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "items_reflink" CONSTRAINT "items_reflink_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "items_related" CONSTRAINT "items_related_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "items_summaries" CONSTRAINT "items_summaries_fkey1" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "quotations" CONSTRAINT "quotations_fkey3" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>     TABLE "summaries" CONSTRAINT "summaries_fkey2" FOREIGN KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>>
>> Everything would be not bad if in the table weren't appeared duplicated records in url column.
>> Any idea how is it possible?
>>
>> Thank you!
>>
>> --
>> Timokhin 'maf' Maxim
>
> It's possible you have index corruption on 9.4.8 version that was not detected.
>
> Try the following query on 9.4.8 to see if any rows are selected. Then you can decide
> how to fix from there.
>
> SELECT a.id, a.url,
>        b.id, b.url
>   FROM items a,
>        items b
>  WHERE a.id <> b.id
>    AND a.url = b.url
>  ORDER by a.id;
>
> --
> Melvin Davidson
> I reserve the right to fantasize.  Whether or not you
> wish to share my fantasy is entirely up to you.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
@ 2017-06-30 13:07     ` Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 13:28       ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  0 siblings, 2 replies; 42+ messages in thread

From: Adrian Klaver @ 2017-06-30 13:07 UTC (permalink / raw)
  To: Timokhin Maxim <ncx2@yandex.com>; Melvin Davidson <melvin6925@gmail.com>; stevenchang1213@gmail.com; +Cc: pgsql-general

On 06/30/2017 04:58 AM, Timokhin Maxim wrote:
> BTW, we are moving using:
> 
> pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v —xlog-method=stream —checkpoint=fast

Going from 9.4 to 9.6 is a major version upgrade and you cannot use 
pg_basebackup for that. Besides I can't see how you even got the 9.6.3 
server to start:

/usr/local/pgsql94/bin/pg_basebackup -D /home/aklaver/pgback_test94 -U 
postgres -p 5412 -v --xlog-method=stream

/usr/local/pgsql96/bin/pg_ctl -D /home/aklaver/pgback_test94/ start
server starting
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.4, 
which is not compatible with this version 9.6.3

> 
> After that we are upping version to 9.6.3.

Given the above how did you actually get 9.6.3 to start?

> I've looked through the documentation https://postgrespro.ru/docs/postgrespro/9.6/app-pgbasebackup and didn't find details about how pg_basebackup works with b-tree indexes.
> Is it possible that pg_basebackup just copies indexes as is and that is cause of corruption. Or it pass indexes as instruction that says "after upping db make indexes" ?
> 
> Thank you.
> 
> 
> -- 
> Timokhin 'maf' Maxim
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
@ 2017-06-30 13:28       ` Melvin Davidson <melvin6925@gmail.com>
  1 sibling, 0 replies; 42+ messages in thread

From: Melvin Davidson @ 2017-06-30 13:28 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Timokhin Maxim <ncx2@yandex.com>; pgsql-general

On Fri, Jun 30, 2017 at 9:07 AM, Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> On 06/30/2017 04:58 AM, Timokhin Maxim wrote:
>
>> BTW, we are moving using:
>>
>> pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v
>> —xlog-method=stream —checkpoint=fast
>>
>
> Going from 9.4 to 9.6 is a major version upgrade and you cannot use
> pg_basebackup for that. Besides I can't see how you even got the 9.6.3
> server to start:
>
> /usr/local/pgsql94/bin/pg_basebackup -D /home/aklaver/pgback_test94 -U
> postgres -p 5412 -v --xlog-method=stream
>
> /usr/local/pgsql96/bin/pg_ctl -D /home/aklaver/pgback_test94/ start
> server starting
> FATAL:  database files are incompatible with server
> DETAIL:  The data directory was initialized by PostgreSQL version 9.4,
> which is not compatible with this version 9.6.3
>
>
>> After that we are upping version to 9.6.3.
>>
>
> Given the above how did you actually get 9.6.3 to start?
>
>
> I've looked through the documentation https://postgrespro.ru/docs/po
>> stgrespro/9.6/app-pgbasebackup and didn't find details about how
>> pg_basebackup works with b-tree indexes.
>> Is it possible that pg_basebackup just copies indexes as is and that is
>> cause of corruption. Or it pass indexes as instruction that says "after
>> upping db make indexes" ?
>>
>> Thank you.
>>
>>
>> --
>> Timokhin 'maf' Maxim
>>
>>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>


*Since you are doing a major version upgrade, the correct way to do that,
depending on the size of your DB, is *

*A. pg_dumpall on old version and pg_reload on new version*

*OR*

*B. pg_upgrade*



*https://www.postgresql.org/docs/9.6/static/upgrading.html
<https://www.postgresql.org/docs/9.6/static/upgrading.html>*--
*Melvin Davidson*
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
@ 2017-06-30 14:33       ` Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-28 14:34         ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  1 sibling, 2 replies; 42+ messages in thread

From: Timokhin Maxim @ 2017-06-30 14:33 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; Melvin Davidson <melvin6925@gmail.com>; stevenchang1213@gmail.com <stevenchang1213@gmail.com>; +Cc: pgsql-general

Sure, here it is.

pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v —xlog-method=stream —checkpoint=fast

/usr/pgsql-9.5/bin/initdb -D /data/upgrade/95/ —encoding=utf8 —locale=ru_RU.utf8 —lc-collate=ru_RU.utf8 —lc-ctype=ru_RU.utf8 —lc-messages=en_US.utf8

Then updating:
/usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.4/bin/ -d /data/upgrade/94 -B /usr/pgsql-9.5/bin/ -D /data/upgrade/95 -k

and so on to 9.6

after that server starts normally.


-- 
Timokhin 'maf' Maxim


30.06.2017, 16:07, "Adrian Klaver" <adrian.klaver@aklaver.com>:
> On 06/30/2017 04:58 AM, Timokhin Maxim wrote:
>>  BTW, we are moving using:
>>
>>  pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v —xlog-method=stream —checkpoint=fast
>
> Going from 9.4 to 9.6 is a major version upgrade and you cannot use
> pg_basebackup for that. Besides I can't see how you even got the 9.6.3
> server to start:
>
> /usr/local/pgsql94/bin/pg_basebackup -D /home/aklaver/pgback_test94 -U
> postgres -p 5412 -v --xlog-method=stream
>
> /usr/local/pgsql96/bin/pg_ctl -D /home/aklaver/pgback_test94/ start
> server starting
> FATAL: database files are incompatible with server
> DETAIL: The data directory was initialized by PostgreSQL version 9.4,
> which is not compatible with this version 9.6.3
>
>>  After that we are upping version to 9.6.3.
>
> Given the above how did you actually get 9.6.3 to start?
>
>>  I've looked through the documentation https://postgrespro.ru/docs/postgrespro/9.6/app-pgbasebackup and didn't find details about how pg_basebackup works with b-tree indexes.
>>  Is it possible that pg_basebackup just copies indexes as is and that is cause of corruption. Or it pass indexes as instruction that says "after upping db make indexes" ?
>>
>>  Thank you.
>>
>>  --
>>  Timokhin 'maf' Maxim
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
@ 2017-06-30 23:30         ` Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-01 04:42           ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  1 sibling, 1 reply; 42+ messages in thread

From: Adrian Klaver @ 2017-06-30 23:30 UTC (permalink / raw)
  To: Timokhin Maxim <ncx2@yandex.com>; Melvin Davidson <melvin6925@gmail.com>; stevenchang1213@gmail.com <stevenchang1213@gmail.com>; +Cc: pgsql-general

On 06/30/2017 07:33 AM, Timokhin Maxim wrote:
> Sure, here it is.
> 
> pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v —xlog-method=stream —checkpoint=fast
> 
> /usr/pgsql-9.5/bin/initdb -D /data/upgrade/95/ —encoding=utf8 —locale=ru_RU.utf8 —lc-collate=ru_RU.utf8 —lc-ctype=ru_RU.utf8 —lc-messages=en_US.utf8
> 
> Then updating:
> /usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.4/bin/ -d /data/upgrade/94 -B /usr/pgsql-9.5/bin/ -D /data/upgrade/95 -k
> 
> and so on to 9.6

The original 9.4 database has the same encoding setup?

FYI, you can use pg_upgrade to go straight from 9.4 to 9.6.

https://www.postgresql.org/docs/9.6/static/pgupgrade.html

"pg_upgrade supports upgrades from 8.4.X and later to the current major 
release of PostgreSQL, including snapshot and alpha releases."

> 
> after that server starts normally.
> 
> 
> -- 
> Timokhin 'maf' Maxim
> 
> 



-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
@ 2017-07-01 04:42           ` Steven Chang <stevenchang1213@gmail.com>
  2017-07-01 14:05             ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 42+ messages in thread

From: Steven Chang @ 2017-07-01 04:42 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Timokhin Maxim <ncx2@yandex.com>; Melvin Davidson <melvin6925@gmail.com>; pgsql-general

Uh...we also met duplicate rows with primary key column through  restoring
database by pg_basebackup.
HAAAA.........................
I don't think its an issue with primary key index corruption.



2017-07-01 7:30 GMT+08:00 Adrian Klaver <adrian.klaver@aklaver.com>:

> On 06/30/2017 07:33 AM, Timokhin Maxim wrote:
>
>> Sure, here it is.
>>
>> pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v
>> —xlog-method=stream —checkpoint=fast
>>
>> /usr/pgsql-9.5/bin/initdb -D /data/upgrade/95/ —encoding=utf8
>> —locale=ru_RU.utf8 —lc-collate=ru_RU.utf8 —lc-ctype=ru_RU.utf8
>> —lc-messages=en_US.utf8
>>
>> Then updating:
>> /usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.4/bin/ -d /data/upgrade/94
>> -B /usr/pgsql-9.5/bin/ -D /data/upgrade/95 -k
>>
>> and so on to 9.6
>>
>
> The original 9.4 database has the same encoding setup?
>
> FYI, you can use pg_upgrade to go straight from 9.4 to 9.6.
>
> https://www.postgresql.org/docs/9.6/static/pgupgrade.html
>
> "pg_upgrade supports upgrades from 8.4.X and later to the current major
> release of PostgreSQL, including snapshot and alpha releases."
>
>
>
>> after that server starts normally.
>>
>>
>> --
>> Timokhin 'maf' Maxim
>>
>>
>>
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-01 04:42           ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
@ 2017-07-01 14:05             ` Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-01 14:51               ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-07-03 01:08               ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  0 siblings, 2 replies; 42+ messages in thread

From: Adrian Klaver @ 2017-07-01 14:05 UTC (permalink / raw)
  To: Steven Chang <stevenchang1213@gmail.com>; +Cc: Timokhin Maxim <ncx2@yandex.com>; Melvin Davidson <melvin6925@gmail.com>; pgsql-general

On 06/30/2017 09:42 PM, Steven Chang wrote:
> Uh...we also met duplicate rows with primary key column through 
>   restoring database by pg_basebackup.
> HAAAA.........................
> I don't think its an issue with primary key index corruption.

That is interesting, more information would be helpful though:

Postgres version?

OS and version?

The pg_basebackup command line invocation?

Why you don't think it is index corruption?


> 
> 
> 
> 2017-07-01 7:30 GMT+08:00 Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>>:
> 
>     On 06/30/2017 07:33 AM, Timokhin Maxim wrote:
> 
>         Sure, here it is.
> 
>         pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql
>         -v —xlog-method=stream —checkpoint=fast
> 
>         /usr/pgsql-9.5/bin/initdb -D /data/upgrade/95/ —encoding=utf8
>         —locale=ru_RU.utf8 —lc-collate=ru_RU.utf8 —lc-ctype=ru_RU.utf8
>         —lc-messages=en_US.utf8
> 
>         Then updating:
>         /usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.4/bin/ -d
>         /data/upgrade/94 -B /usr/pgsql-9.5/bin/ -D /data/upgrade/95 -k
> 
>         and so on to 9.6
> 
> 
>     The original 9.4 database has the same encoding setup?
> 
>     FYI, you can use pg_upgrade to go straight from 9.4 to 9.6.
> 
>     https://www.postgresql.org/docs/9.6/static/pgupgrade.html
>     <https://www.postgresql.org/docs/9.6/static/pgupgrade.html;
> 
>     "pg_upgrade supports upgrades from 8.4.X and later to the current
>     major release of PostgreSQL, including snapshot and alpha releases."
> 
> 
> 
>         after that server starts normally.
> 
> 
>         -- 
>         Timokhin 'maf' Maxim
> 
> 
> 
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-01 04:42           ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  2017-07-01 14:05             ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
@ 2017-07-01 14:51               ` Melvin Davidson <melvin6925@gmail.com>
  1 sibling, 0 replies; 42+ messages in thread

From: Melvin Davidson @ 2017-07-01 14:51 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Steven Chang <stevenchang1213@gmail.com>; Timokhin Maxim <ncx2@yandex.com>; pgsql-general

On Sat, Jul 1, 2017 at 10:05 AM, Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> On 06/30/2017 09:42 PM, Steven Chang wrote:
>
>> Uh...we also met duplicate rows with primary key column through
>>  restoring database by pg_basebackup.
>> HAAAA.........................
>> I don't think its an issue with primary key index corruption.
>>
>
> That is interesting, more information would be helpful though:
>
> Postgres version?
>
> OS and version?
>
> The pg_basebackup command line invocation?
>
> Why you don't think it is index corruption?
>
>
>
>>
>>
>> 2017-07-01 7:30 GMT+08:00 Adrian Klaver <adrian.klaver@aklaver.com
>> <mailto:adrian.klaver@aklaver.com>>:
>>
>>     On 06/30/2017 07:33 AM, Timokhin Maxim wrote:
>>
>>         Sure, here it is.
>>
>>         pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql
>>         -v —xlog-method=stream —checkpoint=fast
>>
>>         /usr/pgsql-9.5/bin/initdb -D /data/upgrade/95/ —encoding=utf8
>>         —locale=ru_RU.utf8 —lc-collate=ru_RU.utf8 —lc-ctype=ru_RU.utf8
>>         —lc-messages=en_US.utf8
>>
>>         Then updating:
>>         /usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.4/bin/ -d
>>         /data/upgrade/94 -B /usr/pgsql-9.5/bin/ -D /data/upgrade/95 -k
>>
>>         and so on to 9.6
>>
>>
>>     The original 9.4 database has the same encoding setup?
>>
>>     FYI, you can use pg_upgrade to go straight from 9.4 to 9.6.
>>
>>     https://www.postgresql.org/docs/9.6/static/pgupgrade.html
>>     <https://www.postgresql.org/docs/9.6/static/pgupgrade.html;
>>
>>     "pg_upgrade supports upgrades from 8.4.X and later to the current
>>     major release of PostgreSQL, including snapshot and alpha releases."
>>
>>
>>
>>         after that server starts normally.
>>
>>
>>         --         Timokhin 'maf' Maxim
>>
>>
>>
>>
>>
>>     --     Adrian Klaver
>>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>>
>>
>>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>


>I don't think its an issue with primary key index corruption.

Well, have you verified that? Try running the following query and make sure
the status column shows "valid" for ALL indexes.

SELECT n.nspname as schema,
       i.relname as table,
       i.indexrelname as index,
       i.idx_scan,
       i.idx_tup_read,
       i.idx_tup_fetch,
       CASE WHEN idx.indisprimary THEN 'pkey'
                  WHEN idx.indisunique  THEN 'uidx'
                  ELSE 'idx'
        END AS type,
       idx.indisexclusion,
       pg_get_indexdef(idx.indexrelid),
       CASE WHEN idx.indisvalid THEN 'valid'
                  ELSE 'INVALID'
        END as statusi,
       pg_relation_size(quote_ident(n.nspname)|| '.' ||
quote_ident(i.relname)) as size_in_bytes,
       pg_size_pretty(pg_relation_size(quote_ident(n.nspname)|| '.' ||
quote_ident(i.relname))) as size
  FROM pg_stat_all_indexes i
  JOIN pg_class c ON (c.oid = i.relid)
  JOIN pg_namespace n ON (n.oid = c.relnamespace)
  JOIN pg_index idx ON (idx.indexrelid =  i.indexrelid )
 WHERE i.relname LIKE '%%'
   AND n.nspname NOT LIKE 'pg_%'
ORDER BY 1, 2, 3;
-- 
*Melvin Davidson*
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-01 04:42           ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  2017-07-01 14:05             ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
@ 2017-07-03 01:08               ` Steven Chang <stevenchang1213@gmail.com>
  2017-07-03 01:18                 ` Re: duplicate key value violates unique constraint and duplicated records Michael Paquier <michael.paquier@gmail.com>
  1 sibling, 1 reply; 42+ messages in thread

From: Steven Chang @ 2017-07-03 01:08 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Timokhin Maxim <ncx2@yandex.com>; Melvin Davidson <melvin6925@gmail.com>; pgsql-general

Hello :

   PG  VERSION : PPAS 9.3 , enterprisedb
   os   version     :  2.6.32-358.el6.x86_64


  pg_basebackup job was not performed by me. But I think it was executed
regularly.
  Any switch or parameter would cause this issue ???

   Why I don't think not a index curruption issue ?
  1. I found this document :

https://www.postgresql.org/message-id/20140811083748.2536.10437%40wrigleys.postgresql.org
   2. Return only on row if  query data using where equal condition, but
got 2 rows by like  condition

Steven

2017-07-01 22:05 GMT+08:00 Adrian Klaver <adrian.klaver@aklaver.com>:

> On 06/30/2017 09:42 PM, Steven Chang wrote:
>
>> Uh...we also met duplicate rows with primary key column through
>>  restoring database by pg_basebackup.
>> HAAAA.........................
>> I don't think its an issue with primary key index corruption.
>>
>
> That is interesting, more information would be helpful though:
>
> Postgres version?
>
> OS and version?
>
> The pg_basebackup command line invocation?
>
> Why you don't think it is index corruption?
>
>
>
>>
>>
>> 2017-07-01 7:30 GMT+08:00 Adrian Klaver <adrian.klaver@aklaver.com
>> <mailto:adrian.klaver@aklaver.com>>:
>>
>>     On 06/30/2017 07:33 AM, Timokhin Maxim wrote:
>>
>>         Sure, here it is.
>>
>>         pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql
>>         -v —xlog-method=stream —checkpoint=fast
>>
>>         /usr/pgsql-9.5/bin/initdb -D /data/upgrade/95/ —encoding=utf8
>>         —locale=ru_RU.utf8 —lc-collate=ru_RU.utf8 —lc-ctype=ru_RU.utf8
>>         —lc-messages=en_US.utf8
>>
>>         Then updating:
>>         /usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.4/bin/ -d
>>         /data/upgrade/94 -B /usr/pgsql-9.5/bin/ -D /data/upgrade/95 -k
>>
>>         and so on to 9.6
>>
>>
>>     The original 9.4 database has the same encoding setup?
>>
>>     FYI, you can use pg_upgrade to go straight from 9.4 to 9.6.
>>
>>     https://www.postgresql.org/docs/9.6/static/pgupgrade.html
>>     <https://www.postgresql.org/docs/9.6/static/pgupgrade.html;
>>
>>     "pg_upgrade supports upgrades from 8.4.X and later to the current
>>     major release of PostgreSQL, including snapshot and alpha releases."
>>
>>
>>
>>         after that server starts normally.
>>
>>
>>         --         Timokhin 'maf' Maxim
>>
>>
>>
>>
>>
>>     --     Adrian Klaver
>>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>>
>>
>>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-01 04:42           ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  2017-07-01 14:05             ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-03 01:08               ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
@ 2017-07-03 01:18                 ` Michael Paquier <michael.paquier@gmail.com>
  2017-07-03 01:53                   ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  0 siblings, 1 reply; 42+ messages in thread

From: Michael Paquier @ 2017-07-03 01:18 UTC (permalink / raw)
  To: Steven Chang <stevenchang1213@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Timokhin Maxim <ncx2@yandex.com>; Melvin Davidson <melvin6925@gmail.com>; pgsql-general

On Mon, Jul 3, 2017 at 10:08 AM, Steven Chang <stevenchang1213@gmail.com> wrote:
> Hello :

Please avoid top-posting.

>    PG  VERSION : PPAS 9.3 , enterprisedb
>    os   version     :  2.6.32-358.el6.x86_64

This is EnterpriseDB's fork of Postgres. Until it can be proved that a
corruption has happened using the community code, it is going to be
hard to say if the problem comes from PostgreSQL itself or from
something that has been changed there.
-- 
Michael


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-01 04:42           ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  2017-07-01 14:05             ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-07-03 01:08               ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
  2017-07-03 01:18                 ` Re: duplicate key value violates unique constraint and duplicated records Michael Paquier <michael.paquier@gmail.com>
@ 2017-07-03 01:53                   ` Steven Chang <stevenchang1213@gmail.com>
  0 siblings, 0 replies; 42+ messages in thread

From: Steven Chang @ 2017-07-03 01:53 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Timokhin Maxim <ncx2@yandex.com>; Melvin Davidson <melvin6925@gmail.com>; pgsql-general

Dear Michael,

    I know what you mean. We also mail the issue to EDB.
   Post here is just to reply Timokhin's case and see could anyone give a
solution.
   EDB's strength is just a orafce moudule enhancement to me,
    and I don't think they could adapt a lot of kernel module codes.

Regards,
Steven

2017-07-03 9:18 GMT+08:00 Michael Paquier <michael.paquier@gmail.com>:

> On Mon, Jul 3, 2017 at 10:08 AM, Steven Chang <stevenchang1213@gmail.com>
> wrote:
> > Hello :
>
> Please avoid top-posting.
>
> >    PG  VERSION : PPAS 9.3 , enterprisedb
> >    os   version     :  2.6.32-358.el6.x86_64
>
> This is EnterpriseDB's fork of Postgres. Until it can be proved that a
> corruption has happened using the community code, it is going to be
> hard to say if the problem comes from PostgreSQL itself or from
> something that has been changed there.
> --
> Michael
>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
  2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
@ 2017-07-28 14:34         ` Timokhin Maxim <ncx2@yandex.com>
  1 sibling, 0 replies; 42+ messages in thread

From: Timokhin Maxim @ 2017-07-28 14:34 UTC (permalink / raw)
  To: pgsql-general; +Cc: Melvin Davidson <melvin6925@gmail.com>; Adrian Klaver <adrian.klaver@aklaver.com>; stevenchang1213@gmail.com <stevenchang1213@gmail.com>

Hello, everybody.
I solved the problem. The index has been corrupted after replication despite it was appeared as not corrupted.
It was solved by recreating the index.
Thank you for the help.

-- 
Пожалуйста!
Используйте кнопку "ответить всем".
Не удаляйте историю переписки.
Спасибо. С уважением, Timokhin 'maf' Maxim


30.06.2017, 17:33, "Timokhin Maxim" <ncx2@yandex.com>:
> Sure, here it is.
>
> pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v —xlog-method=stream —checkpoint=fast
>
> /usr/pgsql-9.5/bin/initdb -D /data/upgrade/95/ —encoding=utf8 —locale=ru_RU.utf8 —lc-collate=ru_RU.utf8 —lc-ctype=ru_RU.utf8 —lc-messages=en_US.utf8
>
> Then updating:
> /usr/pgsql-9.5/bin/pg_upgrade -b /usr/pgsql-9.4/bin/ -d /data/upgrade/94 -B /usr/pgsql-9.5/bin/ -D /data/upgrade/95 -k
>
> and so on to 9.6
>
> after that server starts normally.
>
> --
> Timokhin 'maf' Maxim
>
> 30.06.2017, 16:07, "Adrian Klaver" <adrian.klaver@aklaver.com>:
>>  On 06/30/2017 04:58 AM, Timokhin Maxim wrote:
>>>   BTW, we are moving using:
>>>
>>>   pg_basebackup -h servername -R -P -D /data/upgrade/94 -U pgsql -v —xlog-method=stream —checkpoint=fast
>>
>>  Going from 9.4 to 9.6 is a major version upgrade and you cannot use
>>  pg_basebackup for that. Besides I can't see how you even got the 9.6.3
>>  server to start:
>>
>>  /usr/local/pgsql94/bin/pg_basebackup -D /home/aklaver/pgback_test94 -U
>>  postgres -p 5412 -v --xlog-method=stream
>>
>>  /usr/local/pgsql96/bin/pg_ctl -D /home/aklaver/pgback_test94/ start
>>  server starting
>>  FATAL: database files are incompatible with server
>>  DETAIL: The data directory was initialized by PostgreSQL version 9.4,
>>  which is not compatible with this version 9.6.3
>>
>>>   After that we are upping version to 9.6.3.
>>
>>  Given the above how did you actually get 9.6.3 to start?
>>
>>>   I've looked through the documentation https://postgrespro.ru/docs/postgrespro/9.6/app-pgbasebackup and didn't find details about how pg_basebackup works with b-tree indexes.
>>>   Is it possible that pg_basebackup just copies indexes as is and that is cause of corruption. Or it pass indexes as instruction that says "after upping db make indexes" ?
>>>
>>>   Thank you.
>>>
>>>   --
>>>   Timokhin 'maf' Maxim
>>
>>  --
>>  Adrian Klaver
>>  adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
@ 2017-06-29 23:38 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2017-06-30 09:50   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2 siblings, 1 reply; 42+ messages in thread

From: Adrian Klaver @ 2017-06-29 23:38 UTC (permalink / raw)
  To: Timokhin Maxim <ncx2@yandex.com>; pgsql-general

On 06/29/2017 02:28 AM, Timokhin Maxim wrote:
> Hello.
> We are in process moving to new db from 9.4.8 -> 9.6.3.1. When we did it 
> our application started to throw exception "duplicate key value violates 
> unique constraint" during doing INSERT:

How did move from 9.4.8 --> 9.6.3.1?

Also where are you getting Postgres from? I ask because 9.6.3.1 is not 
a community version or was that just a typo?



> Everything would be not bad if in the table weren't appeared duplicated 
> records in url column.
> Any idea how is it possible?
> Thank you!
> -- 
> Timokhin 'maf' Maxim


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
  2017-06-29 23:38 ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
@ 2017-06-30 09:50   ` Timokhin Maxim <ncx2@yandex.com>
  0 siblings, 0 replies; 42+ messages in thread

From: Timokhin Maxim @ 2017-06-30 09:50 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

<div>Yes, you are right. It's just a typo.</div><div> </div><div>-- <br />Пожалуйста!</div><div>Используйте кнопку "ответить всем".</div><div>Не удаляйте историю переписки.</div><div>Спасибо. С уважением, Timokhin 'maf' Maxim</div><div> </div><div> </div><div> </div><div>30.06.2017, 02:38, "Adrian Klaver" &lt;adrian.klaver@aklaver.com&gt;:</div><blockquote type="cite"><p>On 06/29/2017 02:28 AM, Timokhin Maxim wrote:</p><blockquote> Hello.<br /> We are in process moving to new db from 9.4.8 -&gt; 9.6.3.1. When we did it<br /> our application started to throw exception "duplicate key value violates<br /> unique constraint" during doing INSERT:</blockquote><p><br />How did move from 9.4.8 --&gt; 9.6.3.1?<br /><br />Also where are you getting Postgres from? I ask because 9.6.3.1 is not<br />a community version or was that just a typo?<br /><br /><br /> </p><blockquote> Everything would be not bad if in the table weren't appeared duplicated<br /> records in url column.<br /> Any idea how is it possible?<br /> Thank you!<br /> --<br /> Timokhin 'maf' Maxim</blockquote><p><br /> </p><span>--<br />Adrian Klaver<br /><a href="mailto:adrian.klaver@aklaver.com">adrian.klaver@aklaver.com</a></span></blockquote>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint and duplicated records
  2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
@ 2017-06-30 01:07 ` Steven Chang <stevenchang1213@gmail.com>
  2 siblings, 0 replies; 42+ messages in thread

From: Steven Chang @ 2017-06-30 01:07 UTC (permalink / raw)
  To: Timokhin Maxim <ncx2@yandex.com>; +Cc: pgsql-general

Interesting!! We also met the same situation on PK running on PPAS 9.0 last
night.
When surfing Internet, got returned this URL :

https://www.postgresql.org/message-id/20140811083748.2536.10437%40wrigleys.
postgresql.org


<https://www.postgresql.org/message-id/20140811083748.2536.10437%40wrigleys.postgresql.org;
You can check the reply.

2017-06-29 17:28 GMT+08:00 Timokhin Maxim <ncx2@yandex.com>:

> Hello.
> We are in process moving to new db from 9.4.8 -> 9.6.3.1. When we did it
> our application started to throw exception "duplicate key value violates
> unique constraint" during doing INSERT:
>
> INSERT INTO items (ctime, mtime, pubdate, url, title, description, body,
> status, fulltext_status, orig_id, image_id, video_id, resource_id,
> priority, checksum) VALUES (%(ctime)s, %(mtime)s, %(pubdate)s, %(url)s,
> %(title)s, %(description)s, %(body)s, %(status)s, %(fulltext_status)s,
> %(orig_id)s, %(image_id)s, %(video_id)s, %(resource_id)s, %(priority)s,
> %(checksum)s) RETURNING items.id'
>
> Column url has unique constraint.
>
>
> Also, we saw that during to update value into column status:
> (psycopg2.IntegrityError) duplicate key value violates unique constraint
> "items_url"
>     DETAIL:  Key (url)=(http://www.domainname.
> ru/ap_module/content/article/400-professional/140-professional/11880)
> already exists.
>      [SQL: 'UPDATE items SET status=%(status)s WHERE items.id IN ( ...
> )...
>
>
> Our table:
>
>
>      Column      |            Type             |
>   Modifiers
> -----------------+-----------------------------+------------
> -------------------------------------------------------
>  id              | integer                     | not null default
> nextval(('public.items_id_seq'::text)::regclass)
>  ctime           | timestamp without time zone | not null default now()
>  pubdate         | timestamp without time zone | not null default now()
>  resource_id     | integer                     | not null default 0
>  url             | text                        |
>  title           | text                        |
>  description     | text                        |
>  body            | text                        |
>  status          | smallint                    | not null default 0
>  image           | text                        |
>  orig_id         | integer                     | not null default 0
>  mtime           | timestamp without time zone | not null default now()
>  checksum        | text                        |
>  video_url       | text                        |
>  audio_url       | text                        |
>  content_type    | smallint                    | default 0
>  author          | text                        |
>  video           | text                        |
>  fulltext_status | smallint                    | default 0
>  summary         | text                        |
>  image_id        | integer                     |
>  video_id        | integer                     |
>  priority        | smallint                    |
> Indexes:
>     "items_pkey" PRIMARY KEY, btree (id)
>     "items_url" UNIQUE, btree (url)
>     "items_resource_id" btree (resource_id)
>     "ndx__items__ctime" btree (ctime)
>     "ndx__items__image" btree (image_id)
>     "ndx__items__mtime" btree (mtime)
>     "ndx__items__pubdate" btree (pubdate)
>     "ndx__items__video" btree (video_id)
> Foreign-key constraints:
>     "items_fkey1" FOREIGN KEY (image_id) REFERENCES images(id) ON UPDATE
> CASCADE ON DELETE SET NULL
>     "items_fkey2" FOREIGN KEY (video_id) REFERENCES videos(id) ON UPDATE
> CASCADE ON DELETE SET NULL
> Referenced by:
>     TABLE "cluster_image" CONSTRAINT "cluster_image_fkey2" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "cluster_meta" CONSTRAINT "cluster_meta_item_id_fkey" FOREIGN
> KEY (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "events" CONSTRAINT "events_fkey2" FOREIGN KEY (item_id)
> REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "item_cluster" CONSTRAINT "item_cluster_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_blogs" CONSTRAINT "items_blogs_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_reflink" CONSTRAINT "items_reflink_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_related" CONSTRAINT "items_related_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "items_summaries" CONSTRAINT "items_summaries_fkey1" FOREIGN KEY
> (item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "quotations" CONSTRAINT "quotations_fkey3" FOREIGN KEY (item_id)
> REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>     TABLE "summaries" CONSTRAINT "summaries_fkey2" FOREIGN KEY (item_id)
> REFERENCES items(id) ON UPDATE CASCADE ON DELETE CASCADE
>
>
> Everything would be not bad if in the table weren't appeared duplicated
> records in url column.
> Any idea how is it possible?
>
> Thank you!
>
> --
> Timokhin 'maf' Maxim
>
>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" while performing full vacuum on the database
@ 2018-05-09 07:31 Raghavendra Rao J S V <raghavendrajsv@gmail.com>
  2018-05-09 19:41 ` Re: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" while performing full vacuum on the database Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 1 reply; 42+ messages in thread

From: Raghavendra Rao J S V @ 2018-05-09 07:31 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi,


While performing vacuum full, I have  received the below highlighted error.
Please guide me how to resolve this issue.


​/opt/postgres/9.2/bin/psql -p 5433 --username=cmuser  cpcm -c "*VACUUM
FULL ANALYZE*;"


ERROR:  *duplicate key value violates unique constraint
"pg_statistic_relid_att_inh_index"*
DETAIL:  Key (starelid, staattnum, stainherit)=(18915, 6, f) already exists.

' pg_statistic ' is a meta data table. Is it ok if I remove one duplicated
record from ' pg_statistic' table?.

-- 
Regards,
Raghavendra Rao J S V

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" while performing full vacuum on the database
  2018-05-09 07:31 duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" while performing full vacuum on the database Raghavendra Rao J S V <raghavendrajsv@gmail.com>
@ 2018-05-09 19:41 ` Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 0 replies; 42+ messages in thread

From: Laurenz Albe @ 2018-05-09 19:41 UTC (permalink / raw)
  To: Raghavendra Rao J S V <raghavendrajsv@gmail.com>; pgsql-general@lists.postgresql.org

Raghavendra Rao J S V wrote:
> While performing vacuum full, I have  received the below highlighted error. Please guide me how to resolve this issue.
> 
> 
> /opt/postgres/9.2/bin/psql -p 5433 --username=cmuser  cpcm -c "VACUUM FULL ANALYZE;"
> 
> 
> ERROR:  duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index"
> DETAIL:  Key (starelid, staattnum, stainherit)=(18915, 6, f) already exists.
> 
> ' pg_statistic ' is a meta data table. Is it ok if I remove one duplicated record from ' pg_statistic' table?. 

That is data corruption.

Do you have any idea how you got there?
Any crashes, any unsafe settings? Unreliable hardware?

Fortunately it is only the pg_statistic table.

You can stop the server, start it with

   pg_ctl start -o -O

Then connect as superuser and run

   TRUNCATE pg_statistic;
   ANALYZE;

That should take care of the problem.

It would be a good idea to pg_dumpall the cluster, remove it,
recreate it and load the dump so that you are sure to have
no data corruption.

Yours,
Laurenz Albe




^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* duplicate key value violates unique constraint "chinese_price_infos_pkey"
@ 2019-05-06 11:05 Arup Rakshit <ar@zeit.io>
  2019-05-06 11:08 ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Ray O'Donnell <ray@rodonnell.ie>
  2019-05-06 15:13 ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Michael Nolan <htfoot@gmail.com>
  0 siblings, 2 replies; 42+ messages in thread

From: Arup Rakshit @ 2019-05-06 11:05 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Every time I try to insert I get the error:

docking_dev=# INSERT INTO "chinese_price_infos" ("item_code", "price_cents", "unit", "description", "company_id", "created_at", "updated_at") VALUES ('01GS10001', 6000, 'Lift', 'Shore Crane Rental', '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06 10:49:03.894725', '2019-05-06 10:49:03.894725');
ERROR:  duplicate key value violates unique constraint "chinese_price_infos_pkey"
DETAIL:  Key (id)=(71165) already exists.
docking_dev=# INSERT INTO "chinese_price_infos" ("item_code", "price_cents", "unit", "description", "company_id", "created_at", "updated_at") VALUES ('01GS10001', 6000, 'Lift', 'Shore Crane Rental', '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06 10:49:03.894725', '2019-05-06 10:49:03.894725');
ERROR:  duplicate key value violates unique constraint "chinese_price_infos_pkey"
DETAIL:  Key (id)=(71166) already exists.

Then I found:

docking_dev=# SELECT MAX(id) FROM chinese_price_infos;
  max   
--------
 128520
(1 row)

docking_dev=# SELECT nextval('chinese_price_infos_id_seq');
 nextval 
---------
   71164
(1 row)

Not sure how it is out of sync. How can I fix this permanently. I ran vacuum analyze verbose; still same error.

Thanks,

Arup Rakshit
ar@zeit.io








^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"
  2019-05-06 11:05 duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
@ 2019-05-06 11:08 ` Ray O'Donnell <ray@rodonnell.ie>
  2019-05-06 11:10   ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
  1 sibling, 1 reply; 42+ messages in thread

From: Ray O'Donnell @ 2019-05-06 11:08 UTC (permalink / raw)
  To: Arup Rakshit <ar@zeit.io>; pgsql-general@lists.postgresql.org

On 06/05/2019 12:05, Arup Rakshit wrote:
> Every time I try to insert I get the error:
> 
> docking_dev=# INSERT INTO "chinese_price_infos" ("item_code",
> "price_cents", "unit", "description", "company_id", "created_at",
> "updated_at") VALUES ('01GS10001', 6000, 'Lift', 'Shore Crane
> Rental', '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06
> 10:49:03.894725', '2019-05-06 10:49:03.894725'); ERROR:  duplicate
> key value violates unique constraint "chinese_price_infos_pkey" 
> DETAIL:  Key (id)=(71165) already exists. docking_dev=# INSERT INTO
> "chinese_price_infos" ("item_code", "price_cents", "unit",
> "description", "company_id", "created_at", "updated_at") VALUES
> ('01GS10001', 6000, 'Lift', 'Shore Crane Rental',
> '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06 10:49:03.894725',
> '2019-05-06 10:49:03.894725'); ERROR:  duplicate key value violates
> unique constraint "chinese_price_infos_pkey" DETAIL:  Key
> (id)=(71166) already exists.
> 
> Then I found:
> 
> docking_dev=# SELECT MAX(id) FROM chinese_price_infos; max -------- 
> 128520 (1 row)
> 
> docking_dev=# SELECT nextval('chinese_price_infos_id_seq'); nextval 
> --------- 71164 (1 row)
> 
> Not sure how it is out of sync. How can I fix this permanently. I ran
> vacuum analyze verbose; still same error.


You can fix it by using setval() to set the sequence manually to 
something higher than the highest current id value in the table. 
However, it sounds as if something in the application code may be 
causing problems.... For example, is something generating id values 
without reference to the sequence?

Ray.



-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie





^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"
  2019-05-06 11:05 duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
  2019-05-06 11:08 ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Ray O'Donnell <ray@rodonnell.ie>
@ 2019-05-06 11:10   ` Arup Rakshit <ar@zeit.io>
  2019-05-06 12:19     ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Ray O'Donnell <ray@rodonnell.ie>
  2019-05-07 16:54     ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Frank Alberto Rodriguez <franknigth@gmail.com>
  0 siblings, 2 replies; 42+ messages in thread

From: Arup Rakshit @ 2019-05-06 11:10 UTC (permalink / raw)
  To: Ray O'Donnell <ray@rodonnell.ie>; +Cc: pgsql-general@lists.postgresql.org

Hi,

Thanks for your reply. It is automatic, my app don’t creates ID, it delegates it to the DB. I am using Ruby on Rails app, where we use Postgresql. 

docking_dev=# \d chinese_price_infos;
                                         Table "public.chinese_price_infos"
   Column    |            Type             | Collation | Nullable |                     Default                     
-------------+-----------------------------+-----------+----------+-------------------------------------------------
 id          | integer                     |           | not null | nextval('chinese_price_infos_id_seq'::regclass)
 created_at  | timestamp without time zone |           |          | 
 updated_at  | timestamp without time zone |           |          | 
 item_code   | character varying(255)      |           |          | 
 description | character varying(255)      |           |          | 
 unit        | character varying(255)      |           |          | 
 price_cents | integer                     |           |          | 
 uuid        | uuid                        |           |          | uuid_generate_v4()
 company_id  | uuid                        |           |          | 
Indexes:
    "chinese_price_infos_pkey" PRIMARY KEY, btree (id)
    "index_chinese_price_infos_on_company_id" btree (company_id)




Thanks,

Arup Rakshit
ar@zeit.io



> On 06-May-2019, at 4:38 PM, Ray O'Donnell <ray@rodonnell.ie> wrote:
> 
> On 06/05/2019 12:05, Arup Rakshit wrote:
>> Every time I try to insert I get the error:
>> docking_dev=# INSERT INTO "chinese_price_infos" ("item_code",
>> "price_cents", "unit", "description", "company_id", "created_at",
>> "updated_at") VALUES ('01GS10001', 6000, 'Lift', 'Shore Crane
>> Rental', '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06
>> 10:49:03.894725', '2019-05-06 10:49:03.894725'); ERROR:  duplicate
>> key value violates unique constraint "chinese_price_infos_pkey" DETAIL:  Key (id)=(71165) already exists. docking_dev=# INSERT INTO
>> "chinese_price_infos" ("item_code", "price_cents", "unit",
>> "description", "company_id", "created_at", "updated_at") VALUES
>> ('01GS10001', 6000, 'Lift', 'Shore Crane Rental',
>> '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06 10:49:03.894725',
>> '2019-05-06 10:49:03.894725'); ERROR:  duplicate key value violates
>> unique constraint "chinese_price_infos_pkey" DETAIL:  Key
>> (id)=(71166) already exists.
>> Then I found:
>> docking_dev=# SELECT MAX(id) FROM chinese_price_infos; max -------- 128520 (1 row)
>> docking_dev=# SELECT nextval('chinese_price_infos_id_seq'); nextval --------- 71164 (1 row)
>> Not sure how it is out of sync. How can I fix this permanently. I ran
>> vacuum analyze verbose; still same error.
> 
> 
> You can fix it by using setval() to set the sequence manually to something higher than the highest current id value in the table. However, it sounds as if something in the application code may be causing problems.... For example, is something generating id values without reference to the sequence?
> 
> Ray.
> 
> 
> 
> -- 
> Raymond O'Donnell // Galway // Ireland
> ray@rodonnell.ie






^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"
  2019-05-06 11:05 duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
  2019-05-06 11:08 ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Ray O'Donnell <ray@rodonnell.ie>
  2019-05-06 11:10   ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
@ 2019-05-06 12:19     ` Ray O'Donnell <ray@rodonnell.ie>
  1 sibling, 0 replies; 42+ messages in thread

From: Ray O'Donnell @ 2019-05-06 12:19 UTC (permalink / raw)
  To: Arup Rakshit <ar@zeit.io>; +Cc: pgsql-general@lists.postgresql.org

On 06/05/2019 12:10, Arup Rakshit wrote:
> Hi,
> 
> Thanks for your reply. It is automatic, my app don’t creates ID, it
> delegates it to the DB. I am using Ruby on Rails app, where we use
> Postgresql.

Well, I'm only throwing out wild guesses, but another possibility is 
that rows were loaded manually into that table which had different 
values for the id column; this would lead to what you see.

Anyway, I'd fix the sequence value first with setval(), and then observe 
for a while; if you're still getting id collisions, then something is 
definitely inserting id values independently of the sequence. Remember, 
the sequence is only used as a default for that column; if you insert a 
value into the column, the sequence isn't used and so its current value 
doesn't change.

Ray.

-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie





^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"
  2019-05-06 11:05 duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
  2019-05-06 11:08 ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Ray O'Donnell <ray@rodonnell.ie>
  2019-05-06 11:10   ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
@ 2019-05-07 16:54     ` Frank Alberto Rodriguez <franknigth@gmail.com>
  1 sibling, 0 replies; 42+ messages in thread

From: Frank Alberto Rodriguez @ 2019-05-07 16:54 UTC (permalink / raw)
  To: Arup Rakshit <ar@zeit.io>; Ray O'Donnell <ray@rodonnell.ie>; +Cc: pgsql-general@lists.postgresql.org

You can fix the problem with this query:

SELECT setval('chinese_price_infos_id_seq', sq.val) from ( SELECT
MAX(id) as val FROM chinese_price_infos ) sq;

But you have to search in your application because in some point the
app are inserting the id column instead of leave this task to the DB. 
If you are using some entity framework and the app fill the ID field in
a new entity in some point of the workflow, then when you save the
entity, the framework automatically saves the ID in the DB without
checking if the ID already exist.


Sheers

On Mon, 2019-05-06 at 16:40 +0530, Arup Rakshit wrote:
> Hi,
> 
> Thanks for your reply. It is automatic, my app don’t creates ID, it delegates it to the DB. I am using Ruby on Rails app, where we use Postgresql. 
> 
> docking_dev=# \d chinese_price_infos;
>                                          Table "public.chinese_price_infos"
>    Column    |            Type             | Collation | Nullable |                     Default                     
> -------------+-----------------------------+-----------+----------+-------------------------------------------------
>  id          | integer                     |           | not null | nextval('chinese_price_infos_id_seq'::regclass)
>  created_at  | timestamp without time zone |           |          | 
>  updated_at  | timestamp without time zone |           |          | 
>  item_code   | character varying(255)      |           |          | 
>  description | character varying(255)      |           |          | 
>  unit        | character varying(255)      |           |          | 
>  price_cents | integer                     |           |          | 
>  uuid        | uuid                        |           |          | uuid_generate_v4()
>  company_id  | uuid                        |           |          | 
> Indexes:
>     "chinese_price_infos_pkey" PRIMARY KEY, btree (id)
>     "index_chinese_price_infos_on_company_id" btree (company_id)
> 
> 
> 
> 
> Thanks,
> 
> Arup Rakshit
> ar@zeit.io
> 
> 
> 
> On 06-May-2019, at 4:38 PM, Ray O'Donnell <ray@rodonnell.ie> wrote:
> 
> On 06/05/2019 12:05, Arup Rakshit wrote:
> Every time I try to insert I get the error:
> docking_dev=# INSERT INTO "chinese_price_infos" ("item_code",
> "price_cents", "unit", "description", "company_id", "created_at",
> "updated_at") VALUES ('01GS10001', 6000, 'Lift', 'Shore Crane
> Rental', '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06
> 10:49:03.894725', '2019-05-06 10:49:03.894725'); ERROR:  duplicate
> key value violates unique constraint "chinese_price_infos_pkey" DETAIL:  Key (id)=(71165) already exists. docking_dev=# INSERT INTO
> "chinese_price_infos" ("item_code", "price_cents", "unit",
> "description", "company_id", "created_at", "updated_at") VALUES
> ('01GS10001', 6000, 'Lift', 'Shore Crane Rental',
> '9ae3f8b8-8f3f-491c-918a-efd8f5100a5e', '2019-05-06 10:49:03.894725',
> '2019-05-06 10:49:03.894725'); ERROR:  duplicate key value violates
> unique constraint "chinese_price_infos_pkey" DETAIL:  Key
> (id)=(71166) already exists.
> Then I found:
> docking_dev=# SELECT MAX(id) FROM chinese_price_infos; max -------- 128520 (1 row)
> docking_dev=# SELECT nextval('chinese_price_infos_id_seq'); nextval --------- 71164 (1 row)
> Not sure how it is out of sync. How can I fix this permanently. I ran
> vacuum analyze verbose; still same error.
> 
> 
> You can fix it by using setval() to set the sequence manually to something higher than the highest current id value in the table. However, it sounds as if something in the application code may be causing problems.... For example, is something generating id values without reference to the sequence?
> 
> Ray.
> 
> 
> 
> -- 
> Raymond O'Donnell // Galway // Ireland
> ray@rodonnell.ie
> 
> 
> 
> 

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"
  2019-05-06 11:05 duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
@ 2019-05-06 15:13 ` Michael Nolan <htfoot@gmail.com>
  1 sibling, 0 replies; 42+ messages in thread

From: Michael Nolan @ 2019-05-06 15:13 UTC (permalink / raw)
  To: Arup Rakshit <ar@zeit.io>; +Cc: pgsql-general@lists.postgresql.org

On Mon, May 6, 2019 at 6:05 AM Arup Rakshit <ar@zeit.io> wrote:

SELECT MAX(id) FROM chinese_price_infos;  max   --------  128520(1 row)
SELECT nextval('chinese_price_infos_id_seq');  nextval ---------   71164(1
row)
Not sure how it is out of sync. How can I fix this permanently. I ran
vacuum analyze verbose; still same error

Vacuuming the table doesn't change the fact that your sequence isn't
generating unique keys.  Without knowing the full history of the table, I
can only speculate as to how keys got inserted that are beyond the
sequence's current vlue, but most likely you will need to use the sequence
manipulation function setval to set the sequence to at least one greater
than the current maximum value.
--
Mike Nolan

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* duplicate key value violates unique constraint
@ 2020-03-07 19:29 Ashkar Dev <ashkardev@gmail.com>
  2020-03-07 19:35 ` Fwd: duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
  2020-03-07 20:28 ` Re: duplicate key value violates unique constraint Adrian Klaver <adrian.klaver@aklaver.com>
  2020-03-07 21:13 ` Re: duplicate key value violates unique constraint Ron <ronljohnsonjr@gmail.com>
  0 siblings, 3 replies; 42+ messages in thread

From: Ashkar Dev @ 2020-03-07 19:29 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi all,

how to fix a problem, suppose there is a table with id and username

if I set the id to bigint so the limit is 9223372036854775807
if I insert for example 3 rows
id    username
--    --------------
1     abc
2     def
3     ghi

if I delete all rows and insert one another it is like

id    username
--    --------------
4     jkl


So it doesn't start again from non-available id 1, so what is needed to do
to make the new inserts go into non-available id numbers?

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Fwd: duplicate key value violates unique constraint
  2020-03-07 19:29 duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
@ 2020-03-07 19:35 ` Ashkar Dev <ashkardev@gmail.com>
  2020-03-07 19:54   ` RE: duplicate key value violates unique constraint Dave Bolt <dave@davebolt.co.uk>
  2020-03-07 19:55   ` Re: duplicate key value violates unique constraint David G. Johnston <david.g.johnston@gmail.com>
  2 siblings, 2 replies; 42+ messages in thread

From: Ashkar Dev @ 2020-03-07 19:35 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org

Hi all,

how to fix a problem, suppose there is a table with id and username

if I set the id to bigint so the limit is 9223372036854775807
if I insert for example 3 rows
id    username
--    --------------
1     abc
2     def
3     ghi

if I delete all rows and insert one another it is like

id    username
--    --------------
4     jkl


So it doesn't start again from non-available id 1, so what is needed to do
to make the new inserts go into non-available id numbers?

and if the id reaches the limit and maybe there is some ids that are not
used.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* RE: duplicate key value violates unique constraint
  2020-03-07 19:29 duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
  2020-03-07 19:35 ` Fwd: duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
@ 2020-03-07 19:54   ` Dave Bolt <dave@davebolt.co.uk>
  1 sibling, 0 replies; 42+ messages in thread

From: Dave Bolt @ 2020-03-07 19:54 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org; +Cc: 'Ashkar Dev' <ashkardev@gmail.com>

I have two immediate questions on this.

1)      Do you Need to make sure there are no gaps in the sequence of id values?

2)      Are you ever going to use 9223372036854775807 id values, even with the deletions?

If you want to re-use the id of a deleted row, and it is not going to cause problems elsewhere in your database, you could always have a deleted column in each row instead of actually removing from the table. When you want to insert next, you would just look for the first row where deleted is true and replace it.

Not entirely perfect, but would probably do the job.

 

 

From: Ashkar Dev [mailto:ashkardev@gmail.com] 
Sent: 07 March 2020 19:35
To: pgsql-admin@lists.postgresql.org
Subject: Fwd: duplicate key value violates unique constraint

 

 

Hi all,


how to fix a problem, suppose there is a table with id and username

 

if I set the id to bigint so the limit is 9223372036854775807 

if I insert for example 3 rows

id    username

--    --------------

1     abc

2     def

3     ghi

 

if I delete all rows and insert one another it is like

 

id    username

--    --------------

4     jkl

 

 

So it doesn't start again from non-available id 1, so what is needed to do to make the new inserts go into non-available id numbers?

 

and if the id reaches the limit and maybe there is some ids that are not used.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint
  2020-03-07 19:29 duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
  2020-03-07 19:35 ` Fwd: duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
@ 2020-03-07 19:55   ` David G. Johnston <david.g.johnston@gmail.com>
  2020-03-07 20:21     ` Re: duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
  1 sibling, 1 reply; 42+ messages in thread

From: David G. Johnston @ 2020-03-07 19:55 UTC (permalink / raw)
  To: Ashkar Dev <ashkardev@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

On Sat, Mar 7, 2020 at 12:35 PM Ashkar Dev <ashkardev@gmail.com> wrote:

>
> Hi all,
>
> how to fix a problem, suppose there is a table with id and username
>

You should probably provide the definition though in this case it is
self-evident that you are using bigserial.


> So it doesn't start again from non-available id 1, so what is needed to do
> to make the new inserts go into non-available id numbers?
>

Alter sequence

https://www.postgresql.org/docs/12/sql-altersequence.html


> and if the id reaches the limit and maybe there is some ids that are not
> used.
>

This is highly unlikely.

Is the subject line supposed to relate to this in some way?

You should not worry about any of this in production; and frankly, worrying
about it in development is largely pointless as well.

There is no actual problem here to be fixed.

David J.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint
  2020-03-07 19:29 duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
  2020-03-07 19:35 ` Fwd: duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
  2020-03-07 19:55   ` Re: duplicate key value violates unique constraint David G. Johnston <david.g.johnston@gmail.com>
@ 2020-03-07 20:21     ` Ashkar Dev <ashkardev@gmail.com>
  0 siblings, 0 replies; 42+ messages in thread

From: Ashkar Dev @ 2020-03-07 20:21 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; dave@davebolt.co.uk, Pepe TD Vo <pepevo@yahoo.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

Thanks for answers.

On Sat, Mar 7, 2020 at 10:55 PM David G. Johnston <
david.g.johnston@gmail.com> wrote:

> On Sat, Mar 7, 2020 at 12:35 PM Ashkar Dev <ashkardev@gmail.com> wrote:
>
>>
>> Hi all,
>>
>> how to fix a problem, suppose there is a table with id and username
>>
>
> You should probably provide the definition though in this case it is
> self-evident that you are using bigserial.
>
>
>> So it doesn't start again from non-available id 1, so what is needed to
>> do to make the new inserts go into non-available id numbers?
>>
>
> Alter sequence
>
> https://www.postgresql.org/docs/12/sql-altersequence.html
>
>
>> and if the id reaches the limit and maybe there is some ids that are not
>> used.
>>
>
> This is highly unlikely.
>
> Is the subject line supposed to relate to this in some way?
>
> You should not worry about any of this in production; and frankly,
> worrying about it in development is largely pointless as well.
>
> There is no actual problem here to be fixed.
>
> David J.
>
>

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint
  2020-03-07 19:29 duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
@ 2020-03-07 20:28 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2 siblings, 0 replies; 42+ messages in thread

From: Adrian Klaver @ 2020-03-07 20:28 UTC (permalink / raw)
  To: Ashkar Dev <ashkardev@gmail.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 3/7/20 11:29 AM, Ashkar Dev wrote:
> Hi all,
> 
> how to fix a problem, suppose there is a table with id and username
> 
> if I set the id to bigint so the limit is 9223372036854775807
> if I insert for example 3 rows
> id    username
> --    --------------
> 1     abc
> 2     def
> 3     ghi
> 
> if I delete all rows and insert one another it is like
> 
> id    username
> --    --------------
> 4     jkl

So I am assuming id is of type bigserial or something that has a 
sequence behind it?

> 
> 
> So it doesn't start again from non-available id 1, so what is needed to 
> do to make the new inserts go into non-available id numbers?

If you are sequences then they do not go backwards:

https://www.postgresql.org/docs/12/sql-createsequence.html

"Because nextval and setval calls are never rolled back, sequence 
objects cannot be used if “gapless” assignment of sequence numbers is 
needed. It is possible to build gapless assignment by using exclusive 
locking of a table containing a counter; but this solution is much more 
expensive than sequence objects, especially if many transactions need 
sequence numbers concurrently."

If you want that to happen you will have to roll your own implementation.


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* Re: duplicate key value violates unique constraint
  2020-03-07 19:29 duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
@ 2020-03-07 21:13 ` Ron <ronljohnsonjr@gmail.com>
  2 siblings, 0 replies; 42+ messages in thread

From: Ron @ 2020-03-07 21:13 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org


Asking the same question on multiple lists is strongly frowned upon.

On 3/7/20 1:29 PM, Ashkar Dev wrote:
> Hi all,
>
> how to fix a problem, suppose there is a table with id and username
>
> if I set the id to bigint so the limit is 9223372036854775807
> if I insert for example 3 rows
> id    username
> --    --------------
> 1     abc
> 2     def
> 3     ghi
>
> if I delete all rows and insert one another it is like
>
> id    username
> --    --------------
> 4     jkl
>
>
> So it doesn't start again from non-available id 1, so what is needed to do 
> to make the new inserts go into non-available id numbers?

-- 
Angular momentum makes the world go 'round.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread

* duplicate key value violates unique constraint pg_default_acl_role_nsp_obj_index
@ 2021-01-05 14:49 Andrus <kobruleht2@hot.ee>
  0 siblings, 0 replies; 42+ messages in thread

From: Andrus @ 2021-01-05 14:49 UTC (permalink / raw)
  To: pgsql-general

Hi!

I have used script below to remove all rights from user and add some. 
Today it starts to throw error

ERROR:  duplicate key value violates unique constraint 
"pg_default_acl_role_nsp_obj_index"

DETAIL:  Key (defaclrole, defaclnamespace, defaclobjtype)=(30152, 
186783649, r) already exists.

How to fix this and which is proper way to implement this ?

Code used:

revoke all on all tables in schema 
public,firma1,firma3,firma4,firma5,firma6,firma15,firma17,firma19,firma20,firma21,firma22,firma23,firma24,firma25,firma26,firma27,firma30,firma31,firma32,firma34,firma36,firma37,firma41,firma55,firma59,firma60,firma62,firma63,firma65,firma66,firma67,firma68,firma70,firma71,firma73,firma74,firma76,firma77,firma78,firma79,firma80,firma85,firma88,firma89,firma90,firma91,firma93,firma94,firma95,firma96,firma97,firma98,firma100,firma101,firma102,firma103,firma104,firma105,firma106,firma107,firma110,firma111,firma112,firma148,firma149,firma151,firma152,firma153,firma154,firma155,firma156,firma157,firma158,firma159,firma160,firma163,firma164,firma165,firma166,firma172,firma173,firma174,firma175,firma176,firma177,firma178,firma179,firma180,firma181,firma188,firma189,firma190,firma191,firma192,firma193,firma194,firma195,firma196 
from "testuser" cascade;


revoke all on all sequences in schema 
public,firma1,firma3,firma4,firma5,firma6,firma15,firma17,firma19,firma20,firma21,firma22,firma23,firma24,firma25,firma26,firma27,firma30,firma31,firma32,firma34,firma36,firma37,firma41,firma55,firma59,firma60,firma62,firma63,firma65,firma66,firma67,firma68,firma70,firma71,firma73,firma74,firma76,firma77,firma78,firma79,firma80,firma85,firma88,firma89,firma90,firma91,firma93,firma94,firma95,firma96,firma97,firma98,firma100,firma101,firma102,firma103,firma104,firma105,firma106,firma107,firma110,firma111,firma112,firma148,firma149,firma151,firma152,firma153,firma154,firma155,firma156,firma157,firma158,firma159,firma160,firma163,firma164,firma165,firma166,firma172,firma173,firma174,firma175,firma176,firma177,firma178,firma179,firma180,firma181,firma188,firma189,firma190,firma191,firma192,firma193,firma194,firma195,firma196 
from "testuser" cascade;
revoke all on database 
sba,mef,aus,reta,idd,sam,namm,nevoteks,haa,yle,eevakk,swecon,kose,kliima,best,eeva,kiilikvh,pariisi,nopri,laaneteed,belimo,nkaubandus,netroo,kuluk 
from "testuser" cascade;
revoke all on all functions in schema 
public,firma1,firma3,firma4,firma5,firma6,firma15,firma17,firma19,firma20,firma21,firma22,firma23,firma24,firma25,firma26,firma27,firma30,firma31,firma32,firma34,firma36,firma37,firma41,firma55,firma59,firma60,firma62,firma63,firma65,firma66,firma67,firma68,firma70,firma71,firma73,firma74,firma76,firma77,firma78,firma79,firma80,firma85,firma88,firma89,firma90,firma91,firma93,firma94,firma95,firma96,firma97,firma98,firma100,firma101,firma102,firma103,firma104,firma105,firma106,firma107,firma110,firma111,firma112,firma148,firma149,firma151,firma152,firma153,firma154,firma155,firma156,firma157,firma158,firma159,firma160,firma163,firma164,firma165,firma166,firma172,firma173,firma174,firma175,firma176,firma177,firma178,firma179,firma180,firma181,firma188,firma189,firma190,firma191,firma192,firma193,firma194,firma195,firma196 
from "testuser" cascade;
revoke all on schema 
public,firma1,firma3,firma4,firma5,firma6,firma15,firma17,firma19,firma20,firma21,firma22,firma23,firma24,firma25,firma26,firma27,firma30,firma31,firma32,firma34,firma36,firma37,firma41,firma55,firma59,firma60,firma62,firma63,firma65,firma66,firma67,firma68,firma70,firma71,firma73,firma74,firma76,firma77,firma78,firma79,firma80,firma85,firma88,firma89,firma90,firma91,firma93,firma94,firma95,firma96,firma97,firma98,firma100,firma101,firma102,firma103,firma104,firma105,firma106,firma107,firma110,firma111,firma112,firma148,firma149,firma151,firma152,firma153,firma154,firma155,firma156,firma157,firma158,firma159,firma160,firma163,firma164,firma165,firma166,firma172,firma173,firma174,firma175,firma176,firma177,firma178,firma179,firma180,firma181,firma188,firma189,firma190,firma191,firma192,firma193,firma194,firma195,firma196 
from "testuser" cascade;
revoke sba_owner from "testuser" cascade;

ALTER ROLE "testuser" inherit NOCREATEROLE NOCREATEDB LOGIN;

grant all on all tables in schema 
public,firma193,firma193,firma195,firma196 to "testuser";
grant all on all sequences in schema 
public,firma193,firma193,firma195,firma196 to "testuser";
grant all on database sba to "testuser";
grant all on schema public,firma193,firma193,firma195,firma196 to 
"testuser";
ALTER DEFAULT PRIVILEGES IN SCHEMA 
public,firma193,firma193,firma195,firma196
        GRANT all ON TABLES TO "testuser";
revoke all on  kasutaja,kaspriv,logifail from "testuser" cascade;
grant select on kaspriv,kasutaja to "testuser";
grant update (eesnimi, 
nimi,email,amet,islocked,telefon,language,vabakuup,kasilfirma) on 
kasutaja to "testuser";
grant insert on logifail to "testuser";

Using

PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, 
compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit

Andrus.

^ permalink  raw  reply  [nested|flat] 42+ messages in thread


end of thread, other threads:[~2021-01-05 14:49 UTC | newest]

Thread overview: 42+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 08:19 duplicate key value violates unique constraint "pg_class_relname_nsp_index" Mitu Verma <mitu.verma@ericsson.com>
2015-05-27 08:57 ` Albe Laurenz <laurenz.albe@wien.gv.at>
2015-05-27 09:33   ` Pete Hollobon <postgres@hollobon.com>
2015-05-27 09:51     ` Mitu Verma <mitu.verma@ericsson.com>
2015-05-27 10:07       ` Albe Laurenz <laurenz.albe@wien.gv.at>
2015-05-27 13:05 ` Melvin Davidson <melvin6925@gmail.com>
2015-05-27 13:32   ` Adrian Klaver <adrian.klaver@aklaver.com>
2015-05-27 14:30     ` Tom Lane <tgl@sss.pgh.pa.us>
2017-06-29 09:28 duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
2017-06-29 21:21 ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
2017-06-30 09:49   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
2017-06-30 11:58   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
2017-06-30 13:07     ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
2017-06-30 13:28       ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
2017-06-30 14:33       ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
2017-06-30 23:30         ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
2017-07-01 04:42           ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
2017-07-01 14:05             ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
2017-07-01 14:51               ` Re: duplicate key value violates unique constraint and duplicated records Melvin Davidson <melvin6925@gmail.com>
2017-07-03 01:08               ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
2017-07-03 01:18                 ` Re: duplicate key value violates unique constraint and duplicated records Michael Paquier <michael.paquier@gmail.com>
2017-07-03 01:53                   ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
2017-07-28 14:34         ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
2017-06-29 23:38 ` Re: duplicate key value violates unique constraint and duplicated records Adrian Klaver <adrian.klaver@aklaver.com>
2017-06-30 09:50   ` Re: duplicate key value violates unique constraint and duplicated records Timokhin Maxim <ncx2@yandex.com>
2017-06-30 01:07 ` Re: duplicate key value violates unique constraint and duplicated records Steven Chang <stevenchang1213@gmail.com>
2018-05-09 07:31 duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" while performing full vacuum on the database Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-05-09 19:41 ` Re: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" while performing full vacuum on the database Laurenz Albe <laurenz.albe@cybertec.at>
2019-05-06 11:05 duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
2019-05-06 11:08 ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Ray O'Donnell <ray@rodonnell.ie>
2019-05-06 11:10   ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Arup Rakshit <ar@zeit.io>
2019-05-06 12:19     ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Ray O'Donnell <ray@rodonnell.ie>
2019-05-07 16:54     ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Frank Alberto Rodriguez <franknigth@gmail.com>
2019-05-06 15:13 ` Re: duplicate key value violates unique constraint "chinese_price_infos_pkey" Michael Nolan <htfoot@gmail.com>
2020-03-07 19:29 duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
2020-03-07 19:35 ` Fwd: duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
2020-03-07 19:54   ` RE: duplicate key value violates unique constraint Dave Bolt <dave@davebolt.co.uk>
2020-03-07 19:55   ` Re: duplicate key value violates unique constraint David G. Johnston <david.g.johnston@gmail.com>
2020-03-07 20:21     ` Re: duplicate key value violates unique constraint Ashkar Dev <ashkardev@gmail.com>
2020-03-07 20:28 ` Re: duplicate key value violates unique constraint Adrian Klaver <adrian.klaver@aklaver.com>
2020-03-07 21:13 ` Re: duplicate key value violates unique constraint Ron <ronljohnsonjr@gmail.com>
2021-01-05 14:49 duplicate key value violates unique constraint pg_default_acl_role_nsp_obj_index Andrus <kobruleht2@hot.ee>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox