Re: Processing a work queue - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Processing a work queue
Date
Msg-id 46375203.7040305@magproductions.nl
Whole thread Raw
In response to Re: Processing a work queue  ("Merlin Moncure" <mmoncure@gmail.com>)
Responses Re: Processing a work queue
List pgsql-general
Merlin Moncure wrote:
> ok, here's an example.  I was thinking that my sequence idea might not
> be safe because of race conditions revolving around querying the
> sequence table.  Here is how I might use advisory locks eliminate the

I've seen your name pop up regularly on this list (or are you from
freebsd-stable?), so you kind of got me scratching my head whether you
really don't understand sequences. Kind of hard to imagine... Maybe I
don't understand what you're asking.

Sequences are safe in concurrent use.
* Nextval() always returns a new number, so no two concurrent sessions
can get the same one.
* Currval() is only valid within one session after calling nextval(), so
it's number cannot have been modified by another session.

Why do you expect to need locking?

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

pgsql-general by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: [HACKERS] SOS, help me please, one problem towards the postgresql developement on windows
Next
From: Tom Lane
Date:
Subject: Re: dump-restore only one table