Re: Problems with sequences

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Arturo Perez" <aperez(at)hayesinc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with sequences
Date: 2006-09-07 04:13:11
Message-ID: b42b73150609062113w18314bbkf7aaee0170ae3527@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/6/06, Arturo Perez <aperez(at)hayesinc(dot)com> wrote:
>
> On Sep 6, 2006, at 8:48 PM, Merlin Moncure wrote:
>
> > On 9/6/06, Arturo Perez <aperez(at)hayesinc(dot)com> wrote:
> >> What happens is that if I do a select nextval('seq') I get a number
> >> that's lower than the
> >> max primary key id. This is inspite of my doing
> >> SELECT setval('seq', ((SELECT MAX(seq_ID) FROM table)+1))
> >> ALTER SEQUENCE seq RESTART WITH <max + 1>;
> >> select pg_catalog.setval(seq, <max+1>, true);
> >>
> >
> > are you running those statements to fetch the next key in the table?
> > you might have a race condition there. try wrappnig in a userlock.
> >
> > merlin
>
> No, not running them to get the next key. Just trying to reset the
> sequence so that I stop getting duplicates.
>
> A race condition is unlikely as only one person can actually add
> these things to the system.

If you can reproduce this, it would be of great interest to me and a
lot of other people. Can you turn sql logging on the server and make
it happen? We need to absolutely eliminate any application generated
bugs here.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2006-09-07 04:15:00 Re: Asynchronous trigger
Previous Message Marc G. Fournier 2006-09-07 04:03:01 Re: On DNS for postgresql.org