Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 3764D9FB24E for ; Tue, 24 Oct 2006 11:19:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 04195-08-2 for ; Tue, 24 Oct 2006 14:18:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 96AA29FB1D6 for ; Tue, 24 Oct 2006 11:18:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k9OEILPP008428; Tue, 24 Oct 2006 10:18:23 -0400 (EDT) To: Adriaan Joubert cc: pgsql-jdbc@postgresql.org Subject: Re: currval() race condition on server? In-reply-to: <453DC2BB.70803@albourne.com> References: <453CC859.8070306@albourne.com> <23634.1161613423@sss.pgh.pa.us> <453D42E6.8020102@opencloud.com> <453DC2BB.70803@albourne.com> Comments: In-reply-to Adriaan Joubert message dated "Tue, 24 Oct 2006 10:37:31 +0300" Date: Tue, 24 Oct 2006 10:18:21 -0400 Message-ID: <8427.1161699501@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/107 X-Sequence-Number: 15990 Adriaan Joubert writes: > It feels an awful lot like a timing issue where the sequence > number is retrieved, but there is a delay until currval can use it. I'm > not sure how currval works. There is no "timing issue" in currval --- the server is single-threaded and it's simply not possible that currval wouldn't be aware of a previous nextval. The theory that sounds best to me is the one someone already mentioned about your trigger having a code path that doesn't execute nextval. Another straw to grasp at is connection pooling: are you using it, if so is it conceivable that the SELECT is being issued on a different connection than the UPDATE? regards, tom lane