"Oskars Ozols" <oskars.ozols@gmail.com> writes:
> I have noticed that during high load Postgre starts to use old free sequence
> values (like 156112 in my sample). Sometimes it's ok, but sometimes it fails
> with error above.
This is fairly hard to believe; the sequence code was debugged years
ago. Particularly seeing that your application is evidently supplying
the id value for itself in the INSERT (from a previous nextval, or perhaps
some other way?), it seems much more likely that there's a bug on the
application side.
If you'd like us to pursue this, please put together a self-contained
test case. Assuming it's real, perhaps a simple custom script for
pgbench would serve to show the problem.
regards, tom lane