Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jDbWu-0007mM-VC for pgsql-general@arkaria.postgresql.org; Sun, 15 Mar 2020 22:14:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDbWs-0004i7-Gr for pgsql-general@arkaria.postgresql.org; Sun, 15 Mar 2020 22:14:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jDbWs-0004i0-3L for pgsql-general@lists.postgresql.org; Sun, 15 Mar 2020 22:14:42 +0000 Received: from mout.gmx.net ([212.227.17.20]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jDbWo-0001hM-Tj for pgsql-general@lists.postgresql.org; Sun, 15 Mar 2020 22:14:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1584310474; bh=kQmYnvqlNXS9dNvcozzKptEZYfRLlyZscv3A82fAKHk=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=lm2TN6PMcK0s95yuOyEjG0fOmf0Wo6mjF+nUJBf1V0YPLlg0EAxLoJ1GN38sOUuLb jZQy8ZpEaDzyu2OVtPBbMhwadqHMnbXRGR/j5B64DmChmOxP38HCoWDNE4T8H1nspM /WMTkaywP3S8G+kWkAevJxyNL54m9w8fv8MO72Fo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hermes ([89.14.78.216]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mel3t-1jlqPv1c85-00aiSY for ; Sun, 15 Mar 2020 23:14:34 +0100 Received: from ncq by hermes with local (Exim 4.92) (envelope-from ) id 1jDbWj-0004ki-Gz for pgsql-general@lists.postgresql.org; Sun, 15 Mar 2020 23:14:33 +0100 Date: Sun, 15 Mar 2020 23:14:33 +0100 From: Karsten Hilbert To: pgsql-general@lists.postgresql.org Subject: Re: unexpected chunk number 2 (expected 0) for toast value ... in pg_toast_18536 Message-ID: <20200315221433.GQ467@hermes.hilbert.loc> References: <20200315182349.GL467@hermes.hilbert.loc> <20200315192037.GM467@hermes.hilbert.loc> <3b7214bd-d0b5-e66f-fd29-240f1eb56cdf@aklaver.com> <20200315202100.GO467@hermes.hilbert.loc> <537b5f42-efb7-6833-3c10-d2cf7cd05496@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <537b5f42-efb7-6833-3c10-d2cf7cd05496@aklaver.com> Ma_X_il-Followup-to: d Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net X-Pri_X_ority: 2 (High) User-Agent: Mutt/1.10.1 (2018-07-13) Sender: X-Provags-ID: V03:K1:poT8WMXgcQqhKcYdJLy8IKMBh9VVo8hhuBo46qcH+0vNOM+LQIo X2J6fj9ms9F84S0RRXsNviNIPs1yXtIpzIFoEdKK8tmCMt0c/iJnI6MC/pdSKZJIOF5osD3 GSvMiMO0AC+3XOo0ZFLqA3rgjnCPvU1gO44PZB2Ws0OFZVML44vkxZRFoXaty51GxW+wm8l ODUiSJt5723k+K3icQlPw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:VvHuAkBtxAA=:pAc5orMLorYrD0zQi6TSJY ZmlBxb2dP11cmLvJivvCVlCM2Vt2mx6VUicxNTfeNRvGjsyh67Ecou74eKEF0jcwyQ9OezNIH QWQ3Eq7LkyyPEaDLdXGEP1olmplsy4EcMP3tv96BkQozC3MXwdC1eSNPM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zchJbKfZAbodZZHgyX7iNE1u8PXiyF0EHJ7uolQdWMl+OGAVBZ 2oDvCP8PLHdhNzTqy Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 15, 2020 at 02:35:39PM -0700, Adrian Klaver wrote: > On 3/15/20 1:21 PM, Karsten Hilbert wrote: > > On Sun, Mar 15, 2020 at 12:58:53PM -0700, Adrian Klaver wrote: > > > > > > > We then tried to DELETE the offending row > > > > > > > > > > delete from blobs.doc_obj where pk =3D 82224; > > > > > > > > > > but that, again, shows the "unexpected chunk" problem. > > > > > > > > According to > > > > > > > > http://www.databasesoup.com/2013/10/de-corrupting-toast-tables.ht= ml > > > > > > > > an UPDATE of the row is recommended -- should that work > > > > better than a DELETE ? > > > > > > > > I can't find documentation pointing to a fundamental > > > > implementation difference that suggests so. > > > > > > https://www.postgresql.org/docs/12/storage-toast.html#STORAGE-TOAST-= ONDISK > > > > > > "During an UPDATE operation, values of unchanged fields are normally > > > preserved as-is; so an UPDATE of a row with out-of-line values incur= s no > > > TOAST costs if none of the out-of-line values change." > > > > However, where is the fault in my thinking ? > > > > -> An UPDATE actually *would* change the TOASTed BYTEA field (which is= corrupt). > > > > I had hoped that the DELETE would NOT have to touch the TOAST > > table at all (and thereby not check the chunks) as "all it > > needs to do" is mark the row in the *primary* table as > > not-needed-anymore. > > > > I must be misunderstanding something. > > Except it would also need to delete the toast entries as well. OK, got that. What I now don't understand is how the UPDATE won't have to touch the TOAST table when the TOASTed value *is* UPDATEd: update blobs.doc_obj set data =3D '' where pk =3D the_faulty_row; (data is the BYTEA column) Slightly confused :-) Karsten =2D- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B