Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGV8S-0000ob-7R for pgsql-general@arkaria.postgresql.org; Wed, 09 May 2018 19:52:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fGUyE-0000UE-56 for pgsql-general@arkaria.postgresql.org; Wed, 09 May 2018 19:41:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGUyD-0000U4-SQ for pgsql-general@lists.postgresql.org; Wed, 09 May 2018 19:41:49 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fGUy4-0004nd-Vc for pgsql-general@lists.postgresql.org; Wed, 09 May 2018 19:41:47 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 2C27540ED7; Wed, 9 May 2018 21:41:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id 1fAM3M-akNOI; Wed, 9 May 2018 21:41:37 +0200 (CEST) Message-ID: <1525894896.2269.7.camel@cybertec.at> Subject: Re: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" while performing full vacuum on the database From: Laurenz Albe To: Raghavendra Rao J S V , pgsql-general@lists.postgresql.org Date: Wed, 09 May 2018 21:41:36 +0200 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Raghavendra Rao J S V wrote: > While performing vacuum full, I have received the below highlighted error. Please guide me how to resolve this issue. > > > /opt/postgres/9.2/bin/psql -p 5433 --username=cmuser cpcm -c "VACUUM FULL ANALYZE;" > > > ERROR: duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index" > DETAIL: Key (starelid, staattnum, stainherit)=(18915, 6, f) already exists. > > ' pg_statistic ' is a meta data table. Is it ok if I remove one duplicated record from ' pg_statistic' table?. That is data corruption. Do you have any idea how you got there? Any crashes, any unsafe settings? Unreliable hardware? Fortunately it is only the pg_statistic table. You can stop the server, start it with pg_ctl start -o -O Then connect as superuser and run TRUNCATE pg_statistic; ANALYZE; That should take care of the problem. It would be a good idea to pg_dumpall the cluster, remove it, recreate it and load the dump so that you are sure to have no data corruption. Yours, Laurenz Albe