Re: [SQL] Problem with pg_try_advisory_lock and two connections (seemingly) getting the same lock

2010-07-20 Thread Rob Sargent
You could implement an optimistic lock strategy by placing a 'version' column in the table and increment it on successful 'check-out' and test against the value the user has as he/she tried to act on the record. If some else got there first the second user fails to check-out the queue item. Trigg

[SQL] Problem with pg_try_advisory_lock and two connections (seemingly) getting the same lock

2010-07-20 Thread Brett Hoerner
Hi, I currently have a simple queue written ontop of Postgres. Jobs are inserted and workers periodically check for jobs they can do, do them, and then delete the rows. pg_try_advisory_lock is used to (attempt to) stop two workers from doing the same job. (I'm working on moving to a "real" mess