From: Tom Lane <tgl@sss.pgh.pa.us>
To: Swapnil Vaze <swapvaze28@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: vacuumdb fails with error pg_statistic_relid_att_inh_index constraint violation after upgrade to 9.6
Date: Tue, 28 Nov 2017 09:22:48 -0500
Message-ID: <13146.1511878968@sss.pgh.pa.us> (raw)
In-Reply-To: <CABWf+yTFyZFgnuaLz1OVYdWMOPkeEH6BkvXGoTgBRuUqbS0SVw@mail.gmail.com>
References: <CABWf+yTFyZFgnuaLz1OVYdWMOPkeEH6BkvXGoTgBRuUqbS0SVw@mail.gmail.com>
Swapnil Vaze <swapvaze28@gmail.com> writes:
> We have upgraded our database from 9.5 to 9.6 version.
> After upgrade we ran vacuumdb command and we are getting following error:
> vacuumdb: vacuuming of database "advdfat" failed: ERROR: duplicate key
> value violates unique constraint "pg_statistic_relid_att_inh_index"
> DETAIL: Key (starelid, staattnum, stainherit)=(1259, 1, f) already exists.
Hmm, odd.
> Can anyone help here?
In order of increasing invasiveness:
1. REINDEX pg_statistic_relid_att_inh_index, on the theory that that index
has become corrupt.
2. If #1 fails with a similar message, there must actually be more than
one pg_statistic row with that key. Manually DELETE those rows, then
REINDEX the index, then ANALYZE pg_class to regenerate the deleted
stats. (I suggest reindexing because this case makes it even more likely
that that index is corrupt.)
3. If #2 fails, TRUNCATE pg_statistic, then re-analyze everything to
rebuild the stats.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, swapvaze28@gmail.com
Subject: Re: vacuumdb fails with error pg_statistic_relid_att_inh_index constraint violation after upgrade to 9.6
In-Reply-To: <13146.1511878968@sss.pgh.pa.us>
References: <CABWf+yTFyZFgnuaLz1OVYdWMOPkeEH6BkvXGoTgBRuUqbS0SVw@mail.gmail.com> <13146.1511878968@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox