From: Richard Huxton <dev@archonet.com>
To: cgg007@yahoo.com
To: pgsql-sql@postgresql.org
Subject: Re: FIFO Queue Problems
Date: Fri, 1 Nov 2002 16:20:59 +0000
Message-ID: <200211011620.59439.dev@archonet.com> (raw)
In-Reply-To: <20021101145630.50886.qmail@web13801.mail.yahoo.com>
References: <20021101145630.50886.qmail@web13801.mail.yahoo.com>
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 want.
This means that 1 time in 1000 your query will fail and need to be retried.
HTH
--
Richard Huxton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, cgg007@yahoo.com
Subject: Re: FIFO Queue Problems
In-Reply-To: <200211011620.59439.dev@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox