Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cX6pU-0000q9-3t for pgsql-admin@arkaria.postgresql.org; Fri, 27 Jan 2017 13:44:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cX6pT-0000oC-Db for pgsql-admin@arkaria.postgresql.org; Fri, 27 Jan 2017 13:44:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cX29q-0004mb-E0 for pgsql-admin@postgresql.org; Fri, 27 Jan 2017 08:45:22 +0000 Received: from mx-lv-r1.lailio.net ([178.16.28.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cX29b-0005i3-Ky for pgsql-admin@postgresql.org; Fri, 27 Jan 2017 08:45:20 +0000 Received: from z1.cloud.zimbrazilla.net (unknown [178.16.20.83]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx-lv-r1.lailio.net (Postfix) with ESMTPS id BE352ED205; Fri, 27 Jan 2017 10:46:12 +0200 (EET) Received: from z1.cloud.zimbrazilla.net ([127.0.0.1]) by localhost (z1.cloud.zimbrazilla.net [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id z_8CME3XQd9w; Fri, 27 Jan 2017 10:44:58 +0200 (EET) X-Virus-Scanned: amavisd-new at cloud.zimbrazilla.net Received: from z1.cloud.zimbrazilla.net ([127.0.0.1]) by localhost (z1.cloud.zimbrazilla.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id L5qY4c36S6md; Fri, 27 Jan 2017 10:44:58 +0200 (EET) Received: from z1.cloud.zimbrazilla.net (localhost [127.0.0.1]) by z1.cloud.zimbrazilla.net (Postfix) with ESMTP id 2F627621F7B; Fri, 27 Jan 2017 10:44:58 +0200 (EET) Date: Fri, 27 Jan 2017 10:44:58 +0200 (EET) From: Maris Jansons To: Tom Lane Cc: Jorge Torralba , pgsql-admin Message-ID: <516305076.33441665.1485506698124.JavaMail.zimbra@lailio.net> In-Reply-To: <4224.1485446583@sss.pgh.pa.us> References: <2141896725.20994473.1485356017414.JavaMail.zimbra@lailio.net> <1715943237.23967907.1485379847032.JavaMail.zimbra@lailio.net> <1735117324.25930609.1485423861541.JavaMail.zimbra@lailio.net> <4224.1485446583@sss.pgh.pa.us> Subject: Re: Help: unfixable/undead error - missing chunk number 0 for toast value 413511 in pg_toast_25477 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thread-Topic: Help: unfixable/undead error - missing chunk number 0 for toast value 413511 in pg_toast_25477 Thread-Index: u5FWaPm0AW7Yru8gY7gP5xD39MUUNA== X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Hello, Most excellent!!!=20 Thank you both Jorge and Tom. The script worked correctly after Toms sugges= tion and gave me the correct id of the broken record. After removing this record from the table, reindexing both pg_toast and the= broken table, then vacuuming it =E2=80=93 table is working now as expected. Now backups and selects work again. Thank you and have a great day, Maris. ----- Original Message ----- From: "Tom Lane" To: "Maris Jansons" Cc: "Jorge Torralba" , "pgsql-admin" Sent: Thursday, January 26, 2017 6:03:03 PM Subject: Re: [ADMIN] Help: unfixable/undead error - missing chunk number 0 = for toast value 413511 in pg_toast_25477 Maris Jansons writes: > I have identified the problematic column, in my case it is api_response, = my version of script:=20 > DO $f$=20 > DECLARE=20 > baddata TEXT;=20 > badid INT;=20 > BEGIN=20 > FOR badid IN SELECT id FROM api_logs LOOP=20 > BEGIN=20 > SELECT api_response=20 > INTO baddata=20 > FROM api_logs where id =3D badid;=20 > EXCEPTION=20 > WHEN OTHERS THEN=20 > RAISE NOTICE 'Data for ID % is corrupt', badid;=20 > CONTINUE;=20 > END;=20 > END LOOP;=20 > END;=20 > $f$=20 > However this script finishes without errors, but if I run simple=20 >> select api_response from api_logs;=20 > I get:=20 > ERROR: missing chunk number 0 for toast value 413511 in pg_toast_25477=20 > Maybe I have messed something up in the script?=20 Oh ... what is happening, I think, is that the toast pointers are getting stored into the "baddata" local variable as-is. The problem would only get detected if the system has to fetch the toasted value, and this code doesn't make it do so. You could do something that requires fetching the value, perhaps SELECT api_response || '' INTO baddata ... regards, tom lane --=20 Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin