Re: Concurrency issue under very heay loads - Mailing list pgsql-general

From Greg Smith
Subject Re: Concurrency issue under very heay loads
Date
Msg-id alpine.GSO.2.01.0907161655290.21429@westnet.com
Whole thread Raw
In response to Concurrency issue under very heay loads  ("Raji Sridar (raji)" <raji@cisco.com>)
Responses Re: Concurrency issue under very heay loads
List pgsql-general
On Wed, 15 Jul 2009, Raji Sridar (raji) wrote:

> When multiple clients are concurrently accessing this table and updating
> it, under extermely heavy loads in the system (stress testing), we find
> that the same order number is being generated for multiple clients.

The only clean way to generate sequence numbers without needing to worry
about duplicates is using nextval:
http://www.postgresql.org/docs/current/static/functions-sequence.html

If you're trying to duplicate that logic in your own code, there's
probably a subtle race condition in your implementation that is causing
the bug.

If you had two calls to nextval from different clients get the same value
returned, that might be a PostgreSQL bug.  Given how much that code gets
tested, the more likely case is that there's something to tweak in your
application instead.  I would advise starting with the presumption it's an
issue in your app rather than on the server side of things.

P.S. Posting the same question to two lists here is frowned upon;
pgsql-general is the right one for a question like this.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

pgsql-general by date:

Previous
From: "Relyea, Mike"
Date:
Subject: Re: Error in insert statement
Next
From: Greg Smith
Date:
Subject: Re: Areca 1680 and RHEL/Centos 5.3 issue