FIFO Queue Problems

Поиск
Список
Период
Сортировка
От Chris Gamache
Тема FIFO Queue Problems
Дата
Msg-id 20021101145630.50886.qmail@web13801.mail.yahoo.com
обсуждение исходный текст
Ответы Re: FIFO Queue Problems  (Richard Huxton <dev@archonet.com>)
Re: FIFO Queue Problems  (Bruno Wolff III <bruno@wolff.to>)
Re: FIFO Queue Problems  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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
fifoWHERE 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/


В списке pgsql-sql по дате отправления:

Предыдущее
От: Achilleus Mantzios
Дата:
Сообщение: Re: How do you write this query?
Следующее
От: Maurício Sessue Otta
Дата:
Сообщение: Different size in the DATA directory