inserts failed because of primary key conflict, weird sequence issue. what could cause a reset?

From: jonathan vanasco <postgres(at)2xlp(dot)com>
To: pgsql-general general <pgsql-general(at)postgresql(dot)org>
Subject: inserts failed because of primary key conflict, weird sequence issue. what could cause a reset?
Date: 2017-12-12 23:10:13
Message-ID: 0C538715-CC56-46B2-8E8B-0A565FBE92D2@2xlp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I can't figure out how this happened

I have table where the primary key is a sequence. I was getting a lot of errors on insertions, and noticed the current value was around 65k, but the max id in the database was around 160k. everything works now that i've restarted it, but I can't find any record of a restart sequence accidentally being put in.

the only thing I can think of, is the sequence went up several hundred billion and restarted from 0 when a drive crashed. but that seems incredibly unlikely given the last known actual max id.

does anyone have an idea what could cause this? pg 9.6.6 on ubuntu

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yogesh Sharma 2017-12-13 03:26:24 Re: Size of pg_multixact/members increases 11355
Previous Message Mark Fletcher 2017-12-12 22:36:51 Logical replication blocking alter/drop