Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John R Pierce <pierce(at)hogranch(dot)com>
Cc: dsrich(at)dsrich(dot)net, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time
Date: 2015-07-21 13:40:45
Message-ID: 28061.1437486045@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

John R Pierce <pierce(at)hogranch(dot)com> writes:
> On 7/20/2015 5:39 PM, dsrich(at)dsrich(dot)net wrote:
>> This query (and three other versions using DEFAULT and 'RETURNING payeenum'
>> clauses) fails about half the time with payees_pkey constraint violation.

> when you create a column of pseudotype SERIAL, it creates a SEQUENCE.

Yeah. Have you checked whether the last_value of the sequence is above
the maximum value in the payeenum column? It's not terribly hard to get
that out-of-sync, unfortunately, typically by loading data with
predetermined serial values.

The sequence is probably named payees_payeenum_seq, but psql's \d on
the payees table would show you for sure.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Fabien COELHO 2015-07-21 14:17:10 Re: BUG #13442: ISBN doesn't always roundtrip with text
Previous Message tamiseifo 2015-07-21 13:12:22 BUG #13508: Migration of version error