BUG #18256: spgGetCache() attempts to read to read invalid file for index attached to partitioned table
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Date: 2023-12-21T14:00:01Z
Lists: pgsql-bugs
The following bug has been logged on the website: Bug reference: 18256 Logged by: Alexander Lakhin Email address: exclusion@gmail.com PostgreSQL version: 16.1 Operating system: Ubuntu 22.04 Description: [ a kind of follow-up to bug #18246 ] The following query: CREATE TABLE t(a int, b text) PARTITION BY RANGE (a); CREATE INDEX idx ON t USING spgist(b); SELECT * FROM t; produces an unexpected error: ERROR: could not open file "pg_tblspc/0/PG_16_202307071/0/0": No such file or directory (On master, thanks to commit 049ef3398, which added an Assert in smgr.c, that assertion fails: ... #5 0x000055fcb19630d3 in ExceptionalCondition (conditionName=0x55fcb1b573f8 "RelFileNumberIsValid(rlocator.relNumber)", fileName=0x55fcb1b573ec "smgr.c", lineNumber=159) at assert.c:66 #6 0x000055fcb1770731 in smgropen (rlocator=..., backend=-1) at smgr.c:159 #7 0x000055fcb171e0a7 in RelationGetSmgr (rel=0x7ff29e501e88) at ../../../../src/include/utils/rel.h:575 #8 0x000055fcb171f0ed in ReadBufferExtended (reln=0x7ff29e501e88, forkNum=MAIN_FORKNUM, blockNum=0, mode=RBM_NORMAL, strategy=0x0) at bufmgr.c:803 #9 0x000055fcb171efce in ReadBuffer (reln=0x7ff29e501e88, blockNum=0) at bufmgr.c:737 #10 0x000055fcb1294810 in spgGetCache (index=0x7ff29e501e88) at spgutils.c:261 #11 0x000055fcb1291aff in spgcanreturn (index=0x7ff29e501e88, attno=1) at spgscan.c:1092 #12 0x000055fcb125a3ef in index_can_return (indexRelation=0x7ff29e501e88, attno=1) at indexam.c:762 #13 0x000055fcb166154b in get_relation_info (root=0x55fcb27dd928, relationObjectId=16385, inhparent=false, rel=0x55fcb2700938) at plancat.c:272 #14 0x000055fcb166956e in build_simple_rel (root=0x55fcb27dd928, relid=1, parent=0x0) at relnode.c:339 ... ) Reproduced on REL_16_STABLE (starting from 3c569049b) .. master.
Commits
-
Avoid trying to fetch metapage of an SPGist partitioned index.
- cc3865150b8a 13.14 landed
- ab04c1901d0d 15.6 landed
- 903737c5bf94 17.0 landed
- 375f441bd19c 14.11 landed
- 1771ec9a8290 12.18 landed
- 0977bd64e294 16.2 landed
-
Don't try to open visibilitymap when analyzing a foreign table
- 049ef3398d05 17.0 cited