Re: [SQL] FIFO Queue Problems

2002-11-01 Thread Tom Lane
Wei Weng <[EMAIL PROTECTED]> writes: > Do you need to unlock the table fifo when you are done? That happens at COMMIT. regards, tom lane ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECT

Re: [SQL] FIFO Queue Problems

2002-11-01 Thread Bruno Wolff III
On Fri, Nov 01, 2002 at 14:18:37 -0500, Wei Weng <[EMAIL PROTECTED]> wrote: > Do you need to unlock the table fifo when you are done? Locks only apply for the duration of a transaction. When you commit or roleback the lock will be released. ---(end of broadcast)-

Re: [SQL] FIFO Queue Problems

2002-11-01 Thread Wei Weng
Do you need to unlock the table fifo when you are done? On Fri, 2002-11-01 at 11:51, Tom Lane wrote: > Chris Gamache <[EMAIL PROTECTED]> writes: > > I have a program that claims a row for itself > > > my $processid = $$; > > my $sql_update = < > UPDATE fifo > > set status=$processid

Re: [SQL] FIFO Queue Problems

2002-11-01 Thread Tom Lane
Chris Gamache <[EMAIL PROTECTED]> writes: > I have a program that claims a row for itself > my $processid = $$; > my $sql_update = < UPDATE fifo > set status=$processid > WHERE id = (SELECT min(id) FROM fifo WHERE status=0); > EOS > The problem occurrs when two of the processes

Re: [SQL] FIFO Queue Problems

2002-11-01 Thread Bruno Wolff III
On Fri, Nov 01, 2002 at 06:56:30 -0800, Chris Gamache <[EMAIL PROTECTED]> wrote: > > 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

Re: [SQL] FIFO Queue Problems

2002-11-01 Thread Richard Huxton
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 h

[SQL] FIFO Queue Problems

2002-11-01 Thread Chris Gamache
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 =