From: | Chris Gamache <cgg007(at)yahoo(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | FIFO Queue Problems |
Date: | 2002-11-01 14:56:30 |
Message-ID: | 20021101145630.50886.qmail@web13801.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
I'm having a race condition with a FIFO queue program that I've created...
CREATE TABLE fifo (
id serial,
data varchar(100),
status int4 DEFAULT 0
);
I have a program that claims a row for itself
my $processid = $$;
my $sql_update = <<EOS;
UPDATE fifo
set status=$processid
WHERE id = (SELECT min(id) FROM fifo WHERE status=0);
EOS
I can then
my $sql_get = <<EOS
SELECT data FROM fifo WHERE status=$processid
EOS
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?
__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Roberto de Amorim | 2002-11-01 15:12:51 | pg_restore error |
Previous Message | Ken Guest | 2002-11-01 14:55:24 | postgres on a FreeBSD 4.5 box |
From | Date | Subject | |
---|---|---|---|
Next Message | dima | 2002-11-01 15:22:36 | Re: Different size in the DATA directory |
Previous Message | Maurício Sessue Otta | 2002-11-01 14:25:43 | Re: Different size in the DATA directory |