Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZHXnh-000366-8f for pgsql-bugs@arkaria.postgresql.org; Tue, 21 Jul 2015 13:41:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZHXng-00048S-Iz for pgsql-bugs@arkaria.postgresql.org; Tue, 21 Jul 2015 13:41:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZHXn4-0003RY-Ry for pgsql-bugs@postgresql.org; Tue, 21 Jul 2015 13:41:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZHXmx-0000Ck-Tl for pgsql-bugs@postgresql.org; Tue, 21 Jul 2015 13:41:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t6LDejHB028062; Tue, 21 Jul 2015 09:40:46 -0400 From: Tom Lane To: John R Pierce cc: dsrich@dsrich.net, pgsql-bugs@postgresql.org Subject: Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time In-reply-to: <55ADF703.60606@hogranch.com> References: <20150721003929.9707.40340@wrigleys.postgresql.org> <55ADF703.60606@hogranch.com> Comments: In-reply-to John R Pierce message dated "Tue, 21 Jul 2015 00:38:43 -0700" Date: Tue, 21 Jul 2015 09:40:45 -0400 Message-ID: <28061.1437486045@sss.pgh.pa.us> X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org John R Pierce writes: > On 7/20/2015 5:39 PM, dsrich@dsrich.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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs