Re: using database for queuing operations?

From: Jeff Amiel <jamiel(at)istreamimaging(dot)com>
To: Jeff Amiel <jamiel(at)istreamimaging(dot)com>
Cc: Mark Harrison <mh(at)pixar(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: using database for queuing operations?
Date: 2004-09-20 20:45:22
Message-ID: 414F4162.9080706@istreamimaging.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

.....or instead change the logic to:

So you:

1. select for update, with the criteria outlined
2. Check the state (again) to see of we had that particular race condition.
3. If already processed or in processing, somebody else must already be
working on it....go back to step 1
4, change the state
5. process the image
6. delete.
7 go to step 1.

change the state, then process the image....then delete.

Jeff Amiel wrote:

> Although....it wont really solve the race condition issue...
> you can still have a point where 2 processes select the same
> record...one gets the 'for update' lock on it and the other one just
> waits for it...
> Regardless of the 'state', once that lock releases, the second process
> will grab it.
> In my world I have a 'main' process that selects all the records that
> currently meet the criteria I am interested and them 'parse' them out
> to the sub-processes via unique id.
>
> Dont know if this helps....
> Jeff
>
>
>
> Mark Harrison wrote:
>
>> Jeff Amiel wrote:
>>
>>> Add a column to the nameq table designating the 'state' of the image.
>>> Then your logic changes to "select * from nameq where serial =
>>> (select min(serial) from nameq) and state="UNPROCESSED" (or whatever)
>>> So you select for update, change the state, then process the
>>> image....then delete.
>>
>>
>>
>> Thanks Jeff, I think that will work perfectly for me!
>>
>> Cheers,
>> Mark
>>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2004-09-20 21:02:22 Re: unique constraints on foreign keys
Previous Message Jeff Amiel 2004-09-20 20:41:56 Re: using database for queuing operations?