Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFWHh-00AIPa-7v for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Dec 2023 09:21:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rFWHf-00GrBx-OI for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Dec 2023 09:21:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFWHe-00GrBn-Aa for pgsql-bugs@lists.postgresql.org; Tue, 19 Dec 2023 09:21:03 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFWHb-00B8zi-BK for pgsql-bugs@lists.postgresql.org; Tue, 19 Dec 2023 09:21:01 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 3F7C25C00B3; Tue, 19 Dec 2023 04:20:58 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 19 Dec 2023 04:20:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1702977658; x=1703064058; bh=bRopQYGWGw JrpYq66hX198xBsoNF4SFvoZuA15k767I=; b=i063Y30TWkNZGOETrQ1dsRSBjA lHaokok4jYavaGwxkwcIDliLnPP2ms0Md3vhLNXWJ3+RkamHmAZpJ+tYJSeJ1wU1 RBEeOLZG4Ab+xQlmIP85QFGm4iHvPOlfrUD21IQVkZWQiQAy/PQCViP+o+Cdn7zv VzWbDzex2be1e1x/+ai9QKu5anKHNXs1BA/fkC5lL3C4dZn6HhFA7SUELrzKKJ4H CgVUqlWSOVU06+EnZJktpoBhVEMTlJk/e0Ke80Wgh73eO2LTflQ3Ma3aqbXwNeeG x+V3Okbfzp0gMQmzCfRhTocQqMnk7uX246mxoenEYD6hDv9A8UvRSb0zFTig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1702977658; x=1703064058; bh=bRopQYGWGwJrpYq66hX198xBsoNF 4SFvoZuA15k767I=; b=vyIglDPlFSJquvZ9g/Iiibvpg8KAntgjyPftLciuuAN5 bNngln2YFQ8onJe/C6EoLV1meY73Z99gbMPUJ+ATknI4aLzqUs0GFtS/IMPhORcG QzvhwsWDm2thnJmWPQRNLK+UN9xBF0pew8WoRmc0hE03vSgFBfoLZTIEs68PA9li 9JHDH4cxlSg9hSJQxMWxd0IntI7SYWB+HPDLRTX6pSSjtBKe7Vkfqy/wgvZhF91O aSKBH2IOVyJrHPRTeiyHW/UzO4O0/YJd5Zt4cW3yx0f7tAL246+I+bsklACVPIjK ewsgVUV+zxZIs7gooMDzt/c1RhGlFjqCZqyOP0RogQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddutddgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvvefukfhfgggtuggjsehgtderredttddunecuhfhrohhmpefoihgthhgrvghlucfrrghq uhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvg hrnhepgfehhefgudefudfgfeelgeeiffegfefhkeefffdvheefuddtheetgeelteevkeet necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitg hhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 04:20:56 -0500 (EST) Date: Tue, 19 Dec 2023 18:20:44 +0900 From: Michael Paquier To: Alexander Lakhin Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table Message-ID: References: <18246-f4d9ff7cb3af77e6@postgresql.org> <876b6e52-f068-648a-3f0e-7eaabd57cf77@gmail.com> <11c0916f-82de-decf-c27a-c01a4f8dfcef@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rj9GUDEdlM/X5J3Z" Content-Disposition: inline In-Reply-To: <11c0916f-82de-decf-c27a-c01a4f8dfcef@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rj9GUDEdlM/X5J3Z Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 15, 2023 at 04:00:01PM +0300, Alexander Lakhin wrote: > 13.12.2023 21:00, Alexander Lakhin wrote: >> 13.12.2023 17:18, Michael Paquier wrote: >> > On Wed, Dec 13, 2023 at 09:00:01AM +0000, PG Bug reporting form wrote: >> > > This anomaly can be observed since 8b08f7d48 from 2018-01-19, but IM= O the >> > > culprit is e759854a0 from 2017-02-03, which introduced the following >> > > asymmetry in pgstatindex.c: >> > > if (!IS_INDEX(rel) || !IS_BTREE(rel)) >> > > if (!IS_INDEX(rel) || !IS_GIN(rel)) >> > > But: >> > > if (!IS_HASH(rel)) >> > Fun, let's fix that.=A0 Would you like to write a patch? >>=20 >> Yes, please look at the attached, Thanks. The one for pgstattuple has been applied down to 12 as of a8dd62ef4959. > Looking around, I found the similar index_open() usage within pageinspect, > function hash_bitmap_info(): > CREATE EXTENSION pageinspect; > CREATE TABLE t (a int, b int[], c int) PARTITION BY RANGE (a); > CREATE INDEX c_idx ON t USING hash(c); > SELECT hash_bitmap_info('c_idx'::regclass, 1); >=20 > Leads to: > TRAP: failed Assert("false"), File: "bufmgr.c", Line: 3606, PID: 3984550 Right. > I'm inclined to leave index_open() there for the internal consistency > inside pageinspect, and to use the same condition as in > bt_index_block_validate(), which called by functions bt_page_stats(...), > bt_multi_page_stats(...), bt_page_items(relname text, blkno bigint). >=20 > Functions for other index types, brin/gin/gist, don't read the index, > instead they receive a page as input. Not sure to agree on that. It seems a bit strange to bump on a different error when using a partitioned index or a relkind not allowed by index_open(). And this is after looking at the pgstattuple code. At the end, I've switched to relation_open() for this one, added a test and applied the second patch as of 208470136421. I've checked the rest and yes, it looks like there are no other holes like the ones you have reported for the contrib modules when it comes to index manipulations. -- Michael --rj9GUDEdlM/X5J3Z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmWBYGwACgkQnvQgOdby QH3C6g//QnHDtGDWe1Q8Ohv4+ScaEj85y3ZtRiu89JaktRseNqx7IyfxEaioPJIp UeY01P/oF8FZMyr+krLY8+lmjQOXrDW7k7vsega19PxEDxbVBVoJmxHwkOvI8her PLzVHBregPnamIspADtWDkxDXnhwr0ZmGlT6vu4aXwpW34q6idM+3Un0DLlrKfTw nVwZa1OquuU3oW30fwEDIW96YdNVCjSNVqO5qgyMDGVwCZIAdDS9LAOO2a4+BV6M ZO/NPdexzlVY1MHc1tR3c7x6TAvbIZZyrsU1S58yG1uq4aWguS9ajyeFDfOwMCNT m5FV9IvohQM9DqNAssXBEigbJTPkbFM/Y7MOYd5NRpC2fX+4UkSHtYtBDJUSswJ0 WF+O7JJsea9q/CDsU1cSPm4ez8odMcsufc8dyb3lOEpXng68ohdSFcJeAKo9XRZ7 gWk0gVGuze3/F+fE6wIhj6UJ9nujLtxbclqH8UAEriojMOK5lx/hgwdxCAJszlel yTkNrqMeulKPdtZe+QN+9XUFXPT/4R/4o3L2qVQQbBrZt4xb/o0/7CB68z9NHsyD tatZWEZHI7MwysL+pwMlXKTKViqd8o6rExGsvCiEFJVIwliSZMn5SQ3+4bGXXsIX rwlNGugWtng5V+ai4s7YwkA6yt2PVKuvvwjyKa91GmfPVC6svk8= =DkUl -----END PGP SIGNATURE----- --rj9GUDEdlM/X5J3Z--