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