Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkFOL-0001Tn-Ie for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Nov 2021 00:53:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mkFOK-0005gc-GU for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Nov 2021 00:53:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkFOI-0005gS-EN for pgsql-hackers@lists.postgresql.org; Tue, 09 Nov 2021 00:53:36 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkFOF-0007al-Gv for pgsql-hackers@lists.postgresql.org; Tue, 09 Nov 2021 00:53:34 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 7F8E93201CF6; Mon, 8 Nov 2021 19:53:26 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 08 Nov 2021 19:53:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=EjNhxOAg7EeMWH57NVsZicBQLG+ kraDBCT39H4kIKfY=; b=JHGN8gP94bDHh1n387/gua5iY1EDhODXcymapplHMyZ EOGnJM9ZB/2uLwbnY9KQFnvVPi6wnmT6Qm6H5Pz5Vox5T03e/95GwxrvJrmHV8aQ PNohrnQVkqunfIKdmSszU55MVGpH6rH+17kJqU6NAKqXQRQLKq6nbhvVIIezFNN5 yBVEhmlZFLhJiGlICmOoxQ+PaExKM66Qr7TJim/PcQdJcfnbmUFui3Ozb0uam0db mCJrZFMbjyRqi388CEV4rXaYu085b+BC5npNzu7R9FdcgyKscbsHtewIi5Feo40s b/EDakKZ8KXWvETeeTpHzaqYOb082BOHX5haydJJ3jA== 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-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=EjNhxO Ag7EeMWH57NVsZicBQLG+kraDBCT39H4kIKfY=; b=OoUdj57QoQ6rbjwFMhvLWC /I/TsxyIbC2jyJknsbCw33X8+hRlQfLzgOMhjiCpvMf5Kt+sgtGzIHMEW0sbshFm RSMBCrz1S82uWKJTZmh2ftwRuAVmvH5+Stl+t8Kek7nn3M/6lkZ14CzCmwJVs72j 5vGEC0Q8Djc3fb8ikCiv/UC68mtsGfAQgNov7kzfNKqB08GsLMlPEgesxBEBZAV2 mI4IzEsh9ny8LO0alZozrCb+/P6npSzM1+KejUfj+aOVv2B5r42WA6DrdpuhmTm1 k0KueBV3OFElOBCvSZ0eC17ieW3xWcMQq+z+bbEN2N7hbZ7I/hu7WBxRUI8nsrCg == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrudefgddvgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnh epvdegudeuhfdtueeltedtveejheehieevueeigeelteegleejleeiueeiheegvefhnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrg gvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 Nov 2021 19:53:23 -0500 (EST) Date: Tue, 9 Nov 2021 09:53:15 +0900 From: Michael Paquier To: Kyotaro Horiguchi Cc: bossartn@amazon.com, david@pgmasters.net, peter.eisentraut@2ndquadrant.com, andres@anarazel.de, pgsql-hackers@lists.postgresql.org, jtc331@gmail.com, robertmhaas@gmail.com Subject: Re: Make mesage at end-of-recovery less scary. Message-ID: References: <20210304.155039.2020434514871976864.horikyota.ntt@gmail.com> <20211108.145946.1513355777186578917.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="r7EJ/PzYTNmAczy4" Content-Disposition: inline In-Reply-To: <20211108.145946.1513355777186578917.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --r7EJ/PzYTNmAczy4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 08, 2021 at 02:59:46PM +0900, Kyotaro Horiguchi wrote: > While checking the behavior for the case of missing-contrecord, I > noticed that emode_for_corrupt_record() doesn't work as expected since > readSource is reset to XLOG_FROM_ANY after a read failure. We could > remember the last failed source but pg_wal should have been visited if > page read error happened so I changed the function so that it treats > XLOG_FROM_ANY the same way with XLOG_FROM_PG_WAL. FWIW, I am not much a fan of assuming that it is fine to use XLOG_FROM_ANY as a condition here. The comments on top of emode_for_corrupt_record() make it rather clear what the expectations are, and this is the default readSource. > (Otherwise we see "LOG: reached end-of-WAL at .." message after > "WARNING: missing contrecord at.." message.) + /* broken record found */ + ereport(WARNING, + (errmsg("redo is skipped"), + errhint("This suggests WAL file corruption. You might need to check the database."))); This looks rather scary to me, FWIW, and this could easily be reached if one forgets about EndOfWAL while hacking on xlogreader.c. Unlikely so, still. + report_invalid_record(state, + "missing contrecord at %X/%X", + LSN_FORMAT_ARGS(RecPtr)); Isn't there a risk here to break applications checking after error messages stored in the WAL reader after seeing a contrecord? + if (record->xl_tot_len == 0) + { + /* This is strictly not an invalid state, so phrase it as so. */ + report_invalid_record(state, + "record length is 0 at %X/%X", + LSN_FORMAT_ARGS(RecPtr)); + state->EndOfWAL = true; + return false; + } This assumes that a value of 0 for xl_tot_len is a synonym of the end of WAL, but cannot we have also a corrupted record in this case in the shape of xl_tot_len being 0? We validate the full record after reading the header, so it seems to me that we should not assume that things are just ending as proposed in this patch. -- Michael --r7EJ/PzYTNmAczy4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmGJxnsACgkQnvQgOdby QH0DZA/+JDdfv80/pqYRefNqedAGK2E+gUPCLfQLlitg5Kwvj4oRP1ETcCV+WBJT Qtr/tc2aL1eOwphdWHGeB2DEdKz4CSLFDNr2oy0zo0ts0p0q01HSv2lGfaEUy6qT uLuTKpzvqMvlf6TudVqh94LaQ0AnL2I4e6a6TQsv0Mpbr5E2TDenO6NQ0wSZ6HLD dKeRtgG1CI4XgpXdMrky7vtuie8WnMqcT5bXWZ32nBymhiS3eqvPuawoCYamuCsN CeHVOQjHt+wDpBCeEl7hipi8UAfVLFZBVJc5B3koz5YsDv+9EWEwwa7YTuJmJpL0 ENjKR8S6zQO+cijdW3kevH8AYHhFrp+1bkLCYRiJ6XUYHA96au/V/WMlCyGXDv6u CKXNc5XWkupeB7ekx0vLAFqNelioqj8oCrh4dttzqXGS5uXbxWR/RojH3iHv4EOM f/uzx5N7QKOUxmZNh0sLgAqov8NRBQNAJMLb7RMdGaB+zT49J5uE+OOw/II8/JlZ gj+w1IHjTvbtzwGUv6nEtRrU7CCJM+DYw3Mi36NPr7fPFw/XXY4Z1vdrPFT/w8I/ UTz/eYMqPJ4yAXVylUNOPiwh5mrjeX+4UFtKjUhaeOKqgUjIJ8XwiYVX4pV3gy89 InG92BQAWnk8qEcz3QHNNzINi9kjHrIVWSIySJEhQMwwOJfyqeI= =MQpK -----END PGP SIGNATURE----- --r7EJ/PzYTNmAczy4--