Re: Processing a work queue

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: "John D(dot) Burger" <john(at)mitre(dot)org>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Processing a work queue
Date: 2007-05-01 14:43:15
Message-ID: 46375203.7040305@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)magproductions(dot)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 //

In response to

Responses

Browse pgsql-general by date

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