Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBfmr-0001SZ-KV for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Apr 2018 12:14:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fBfmp-0002Bt-Oq for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Apr 2018 12:14:07 +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.89) (envelope-from ) id 1fBfmn-0002Bd-Ie for pgsql-bugs@lists.postgresql.org; Thu, 26 Apr 2018 12:14:07 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBfmj-0000tS-Lr for pgsql-bugs@postgresql.org; Thu, 26 Apr 2018 12:14:04 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id D9688217FD; Thu, 26 Apr 2018 08:13:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 26 Apr 2018 08:13:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=f/6O2nVXawBC4QAHYMPqlXacv9dv26TPqgoO28IkN78=; b=MeKyCIbv liL9LnDWGlN6hfomdeRsxVrPUBrdA/1R6jfOFcUoR5ARCwtK6Fu7H46jBLY1hF47 qk6dIO1ysdsGCCZ4STfWS79QOr670JsA4SoPCQYLQA/pnBEk1/m5hqQRc5YpI4sx XKWsauKIgOldEmdXJeCEnrsytp4vC7Zn8Uhz8v8hmEOckGCGvBP7nsWSB9WBvBxS Vm0QYg+45OFM2z2G++KpDSkZDGs1U2Xg/SfkoxlQcino7NmLFixXw5b90QjeswKP PZRGhrtWgIUN7p81XRM+ZiQN+c3zvMj1q69iMsR31Jv7gUZR9F/MshCOCGP7MNiv KU1Vq2YoqPfyCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=f/6O2nVXawBC4QAHYMPqlXacv9dv2 6TPqgoO28IkN78=; b=VU+wLO6xvj7P5ljWY4mw+CMa3cSi0rFyFu17fWWDctS4j brfwBuMiQVpvEM7ohc3k1iA4Da/jwdUpeWGqCtod11bbZQ9HkweOfBPEkZOCNQ/H Ohv4tPJtxl0v0IHtnkiP394/CBch9opgScY9wCGxS6nsDjqgRkBPh01WjF5jA7Jv c4MSzDxVwkVRbE5eTZ85Zcw1/8uaSYvsRxujhES4ljbUlNotrBcz8JVhfqvimCg+ W0KxLasmR9vwC6C2/pcTRtvh2/GOF4PsOqaKkVBAwBRCVnWm0+GZlOCudKjsm2LQ 60PQabObw6KNRrkxbsgpEkIGMAOh44u/174CJrFAg== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id BBBA4E4921; Thu, 26 Apr 2018 08:13:56 -0400 (EDT) Date: Thu, 26 Apr 2018 21:13:48 +0900 From: Michael Paquier To: Kyotaro HORIGUCHI Cc: emre@hasegeli.com, tomas.vondra@2ndquadrant.com, pgsql-bugs@postgresql.org, gurkan.gur@innogames.com, david.pusch@innogames.com, patrick.schmidt@innogames.com, pgsql-hackers@lists.postgresql.org Subject: Re: Standby corruption after master is restarted Message-ID: <20180426121348.GA2365@paquier.xyz> References: <1da55c73-4bd1-f13e-2d4b-c4049ffd73f5@2ndquadrant.com> <20180426.195304.118373455.horiguchi.kyotaro@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline In-Reply-To: <20180426.195304.118373455.horiguchi.kyotaro@lab.ntt.co.jp> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Apr 26, 2018 at 07:53:04PM +0900, Kyotaro HORIGUCHI wrote: > I think this behavior is a bug. XLogReadRecord is considering the > case but palloc_extended() breaks it. So in the attached, add a > new flag MCXT_ALLOC_NO_PARAMERR to palloc_extended() and > allocate_recordbuf calls it with the new flag. That alone fixes > the problem. However, the patch frees read state buffer facing > errorneous records since such records can leave a too-large > buffer allocated. This problem is already discussed here: https://commitfest.postgresql.org/18/1516/ And here is the thread: https://www.postgresql.org/message-id/flat/0A3221C70F24FB45833433255569204D1F8B57AD@G01JPEXMBYT05 Tsunakawa-san and I discussed a couple of approaches. Extending palloc_extended so as an incorrect length does not result in an error is also something that crossed by mind, but the length handling is different on the backend and the frontend, so I discarded the idea you are proposing here and instead relied on a check with AllocSizeIsValid, which gives a more simple patch: https://www.postgresql.org/message-id/20180314052753.GA16179%40paquier.xyz This got no interest from committers yet unfortunately, but I think that this is a real problem which should be back-patched :( -- Michael --k+w/mQv8wyuph6w0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlrhwnwACgkQnvQgOdby QH1OoxAAoJur8wKiLw/D3+h+V2QeuXOoUTxj/EmI3DNXi1ZuepMWmKXMgzVU4Q7v seOc0dU6I8K3PexnAET6yx1jK1WfwfVntGlqNaHQ6A0G1VVfMV66J0nWDehsfw9P Zly68Ggrp5St9UtoCmzaZl+RCZqr8cA3gRxQ3InnlecIO/Jzi/hrtqBVIxd/OdHX wS4wS0fpBg6xcet1gU+bQ8meuvPauCfNLDpfMzMkFKGwqL0NVFtkBsSSLhNHBpx4 qPIe/h8lMeGRQkGa1ks5i5M8mU4/rNTlFFEkV6feHCy+0iMrA00ksJ4f/t3zhLeo 8nAbNC9o64ZPRii57UX5+ZqBMYiyOsjMktDKsTrolysq6S8Q12WeyLgYWywj3MhH 15WEvBIGEjA7aEjiB8OrjEnwSYilp0ss0o8Z4QuYhKLXFZFgj1ZiiwOICuDbwnYi FVfD9/kHZSUsNEcIszTG9UfyjHmf8cRcQNLfz74LarJhTlzLcacmxEjn1/FhKJ8r CNU5k5yEynnEdZU3a/hYyHUv4LDHXND9GMsAeq26nRlOKEPJXcs7Nrk1quTJvf0n 6hCZ/sMgDxuckr6FoMxVVCEc933tL/dAA7tV2JOMcwbRXJGyaR1ptWyIvJaSp7jc xr8EPRyZ6YleBL/wHhMkIKUFdzIOWtqYOaz59JPpaXSRf4AlN9M= =ny8W -----END PGP SIGNATURE----- --k+w/mQv8wyuph6w0--