Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D7A3C475E20 for ; Fri, 1 Nov 2002 11:29:56 -0500 (EST) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by postgresql.org (Postfix) with ESMTP id 49C1B474E53 for ; Fri, 1 Nov 2002 11:29:56 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 187egK-00048f-0X; Fri, 01 Nov 2002 16:30:00 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 84E9417823; Fri, 1 Nov 2002 16:21:00 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id E83A81781B; Fri, 1 Nov 2002 16:20:59 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: cgg007@yahoo.com, pgsql-sql@postgresql.org Subject: Re: FIFO Queue Problems Date: Fri, 1 Nov 2002 16:20:59 +0000 User-Agent: KMail/1.4.3 References: <20021101145630.50886.qmail@web13801.mail.yahoo.com> In-Reply-To: <20021101145630.50886.qmail@web13801.mail.yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211011620.59439.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/8 X-Sequence-Number: 10150 On Friday 01 Nov 2002 2:56 pm, Chris Gamache wrote: > I'm having a race condition with a FIFO queue program that I've created... > I have a program that claims a row for itself [code sample] > The problem occurrs when two of the processes grab the exact same row at > the exact same instant. It happens roughly 1 out of 1000 times. I'm not > sure if setting the transactions to serializable would fix the problem > since it occurrs between different postmasters. > > My experience with Views and Triggers is minimal. Would they even help? > Could someone suggest a better FIFO queue method? Check out SELECT FOR UPDATE - this locks the row and should do what you wan= t.=20 This means that 1 time in 1000 your query will fail and need to be retried. HTH --=20 Richard Huxton