X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 43CF652B0F for ; Sat, 6 Aug 2005 23:47:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84037-04 for ; Sun, 7 Aug 2005 02:47:08 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id B4730529AA for ; Sat, 6 Aug 2005 23:47:06 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j772l3RT041598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 6 Aug 2005 20:47:05 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j772l2Ux078826; Sat, 6 Aug 2005 20:47:02 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j772l2DG078825; Sat, 6 Aug 2005 20:47:02 -0600 (MDT) (envelope-from mfuhr) Date: Sat, 6 Aug 2005 20:47:02 -0600 From: Michael Fuhr To: Robert Perry Cc: pgsql-admin@postgresql.org Subject: Re: Duplicate Key -- Have I missed something Message-ID: <20050807024702.GA78766@winnie.fuhr.org> References: <2994A7D7-EB9B-47B6-B782-BA0E6A71187D@lodestonetechnologies.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2994A7D7-EB9B-47B6-B782-BA0E6A71187D@lodestonetechnologies.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200508/80 X-Sequence-Number: 18399 On Sat, Aug 06, 2005 at 10:00:10PM -0400, Robert Perry wrote: > I have a production environment that is running the code that > caused this problem about once every 30 seconds or so, with two > clients. It normally runs very well, but I was suddenly hit with a > duplicate key violation for a table where the primary key is > generated in part from sequence. > > How might this have happen? Have any values been inserted that weren't obtained from the sequence? What are the results of the following queries? SELECT max(tid) FROM game_pay_cash_coupon_trans; SELECT * FROM game_pay_cash_coupon_trans_seq; (You already showed the second query, but let's see it again run at the same time as the first). -- Michael Fuhr