| From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
|---|---|
| To: | krah(dot)tm(at)gmail(dot)com, pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: running ANALYZE results in => duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" |
| Date: | 2023-09-06 08:21:38 |
| Message-ID: | 914c8b13fe9c1fb41a3b673b59813a210c72c92f.camel@cybertec.at |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wed, 2023-09-06 at 09:46 +0200, Torsten Krah wrote:
> I am running that one (official docker image)
>
> PostgreSQL 13.11 (Debian 13.11-1.pgdg110+1) on x86_64-pc-linux-gnu,
> compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
>
> and one of my nightly jobs reported that error yesterday when running
> an "ANALYZE":
>
> FEHLER: doppelter Schlüsselwert verletzt Unique-Constraint »pg_statistic_relid_att_inh_index«
> Detail: Schlüssel »(starelid, staattnum, stainherit)=(2609, 4, f)« existiert bereits.
>
> which should translate to something like:
>
> ERROR: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index"
> > DETAIL: Key (starelid, staattnum, stainherit)=(2609, 4, f) already exists.
>
>
> Anyone an idea what's wrong?
Yes: the metadata table pg_statistic has data corruption.
> Maybe (not?) related but sometimes the analyze does fail with:
>
> ERROR: attempted to delete invisible tuple
That also looks like data corrupton, albeit different one.
> Both errors are only happening here and there - so I don't have a
> reproducer, but still I am curious what is wrong here with me running
> an "ANALYZE" after my data import.
To fix the "pg_statistic" error:
- take down time
- set "allow_system_mods = on"
- TRUNCATE pg_statistic;
- ANALYZE;
You are lucky that the corrupted table is one that holds data that can be rebuilt.
Yours,
Laurenz Albe
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Torsten Krah | 2023-09-06 08:33:31 | Re: running ANALYZE results in => duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" |
| Previous Message | Laurenz Albe | 2023-09-06 08:11:55 | Re: Postgres partition max limit |