Re: BUG #15967: Sequence generation using NEXTVAL() fails on 64bit systems - Mailing list pgsql-bugs

From Merlin Moncure
Subject Re: BUG #15967: Sequence generation using NEXTVAL() fails on 64bit systems
Date
Msg-id CAHyXU0yt1RzjhYrJ2M1Y4EPkRo8ZaWOer4SOuM1UveHUFsLb-A@mail.gmail.com
Whole thread Raw
In response to Re: BUG #15967: Sequence generation using NEXTVAL() fails on 64bit systems  (Christoph Ziegenberg <ziegenberg@web.de>)
List pgsql-bugs
On Wed, Aug 21, 2019 at 8:27 AM Christoph Ziegenberg <ziegenberg@web.de> wrote:
>
> Good news: We finally found the error.
>
> It was a trigger on one table that updated the sequence using setval()... Of course this cannot work and I don't know
whythis was added (perhaps for a migration script?).
 
>
> This use of setval() via the trigger was missing in the Postgres statement log (perhaps because it was a PERFORM
statement?),so we didn't find it earlier.
 
>
> Sorry and thanks for your help to all.

No worries, glad you found the issue.  I mean, nextval() is probably
the most commonly trafficked function in the database and is dead
reliable for millions of users, so there had to be another
explanation, right? :-).   setval() is an extremely dangerous function
outside of cases related to restoring data; it modifies state outside
of transactional guarantees.   if you saw it in code not guarded by
some kind of lock you ought to be suspicious.

merlin



pgsql-bugs by date:

Previous
From: Christoph Ziegenberg
Date:
Subject: Re: BUG #15967: Sequence generation using NEXTVAL() fails on 64bit systems
Next
From: Michael Paquier
Date:
Subject: Re: BUG #15954: Unable to alter partitioned table to set logged