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@xxxxxxxxxxxxx http://www.gregsmith.com Baltimore, MD -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general