Re: FIFO Queue Problems - Mailing list pgsql-sql

From Richard Huxton
Subject Re: FIFO Queue Problems
Date
Msg-id 200211011620.59439.dev@archonet.com
Whole thread Raw
In response to FIFO Queue Problems  (Chris Gamache <cgg007@yahoo.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Tim Perdue
Date:
Subject: Re: Different size in the DATA directory
Next
From: "Ross J. Reedstrom"
Date:
Subject: Re: Selecting * from the base table but getting the inheriteds