Thread
Commits
-
pageinspect: Fix failure with hash_bitmap_info() for partitioned indexes
- f610d4f119b5 12.18 landed
- 586c6a091f85 13.14 landed
- bfbe4a146e37 14.11 landed
- 2e08440d61ea 15.6 landed
- 7f68b14629c1 16.2 landed
- 208470136421 17.0 landed
-
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes
- bd2d3c92812f 12.18 landed
- b4c1d255c17c 13.14 landed
- f729fdab450f 14.11 landed
- b745f168042e 15.6 landed
- b4948ed66695 16.2 landed
- a8dd62ef4959 17.0 landed
-
Don't try to open visibilitymap when analyzing a foreign table
- 049ef3398d05 17.0 cited
-
BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table
The Post Office <noreply@postgresql.org> — 2023-12-13T09:00:01Z
The following bug has been logged on the website: Bug reference: 18246 Logged by: Alexander Lakhin Email address: exclusion@gmail.com PostgreSQL version: 16.1 Operating system: Ubuntu 22.04 Description: The following script: CREATE EXTENSION pgstattuple; CREATE TABLE t (a int, b int[], c int) PARTITION BY RANGE (a); CREATE INDEX a_idx ON t USING btree(a); CREATE INDEX b_idx ON t USING gin(b); CREATE INDEX c_idx ON t USING hash(c); SELECT pgstatindex('a_idx'); SELECT pgstatginindex('b_idx'); SELECT pgstathashindex('c_idx'); gives an unexpected error for the hash index: ERROR: could not open file "pg_tblspc/0/PG_16_202307071/0/0": No such file or directory while for btree and hash indexes errors are more adequate: ERROR: relation "a_idx" is not a btree index ERROR: relation "b_idx" is not a GIN index Reproduced on REL_12_STABLE .. master. (On master, thanks to commit 049ef3398, which added an Assert in smgr.c, that assertion fails.) This anomaly can be observed since 8b08f7d48 from 2018-01-19, but IMO 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)) -
Re: BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table
Michael Paquier <michael@paquier.xyz> — 2023-12-13T14:18:14Z
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 IMO 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. Would you like to write a patch? -- Michael
-
Re: BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table
Alexander Law <exclusion@gmail.com> — 2023-12-13T18:00:00Z
Hello Michael, 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 IMO 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. Would you like to write a patch? Yes, please look at the attached, I've decided to change also index_open() -> relation_open() because index_open() only adds a check, that is not suitable for this concrete case, so there is no much sense to use the different function. (In fact, that check was good enough at the time of e759854a0, but 8b08f7d48 changed it.) As a result, error messages for hash indexes are becoming consistent with other indexes. Also I've added a test case for the issue, but maybe it's superfluous... Best regards, Alexander
-
Re: BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table
Alexander Law <exclusion@gmail.com> — 2023-12-15T13:00:01Z
13.12.2023 21:00, Alexander Lakhin wrote: > Hello Michael, > > 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 IMO 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. Would you like to write a patch? > > Yes, please look at the attached, 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); Leads to: TRAP: failed Assert("false"), File: "bufmgr.c", Line: 3606, PID: 3984550 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). Functions for other index types, brin/gin/gist, don't read the index, instead they receive a page as input. Please look at the additional patch. Best regards, Alexander -
Re: BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table
Michael Paquier <michael@paquier.xyz> — 2023-12-19T09:20:44Z
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 IMO 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. Would you like to write a patch? >> >> 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); > > 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). > > 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