BUG #16694: Server hangs in 100% CPU loop when decompressing a specific TOAST Postgis linestring - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16694: Server hangs in 100% CPU loop when decompressing a specific TOAST Postgis linestring
Date
Msg-id 16694-f107871e499ec114@postgresql.org
Whole thread Raw
Responses Re: BUG #16694: Server hangs in 100% CPU loop when decompressing a specific TOAST Postgis linestring
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16694
Logged by:          Tom Vijlbrief
Email address:      tvijlbrief@gmail.com
PostgreSQL version: 13.0
Operating system:   Ubuntu 18.04
Description:

See https://trac.osgeo.org/postgis/ticket/4776 for a full description

Summary:

st_numpoints() fetches the whole TOAST object and works fine but
st_geometrytype() just requests a slice at the front of the TOAST object.
This looks to me like a low level issue with Postgres13 and TOAST objects of
a specific size and or compression behavior. 

Could be related to this Postgresql rel_13 commit:

https://github.com/postgres/postgres/commit/11a078cf87ffb611d19c7dec6df68b41084ad9c9

Disabling compression elimates the hang:

 alter table demo alter column wkb_geometry set storage external; 

Top of stack trace when hanging:

#0  pglz_decompress (source=source@entry=0x55584d6c39b0 "", slen=<optimized
out>,
    dest=dest@entry=0x55584d6c3a3c "", rawsize=rawsize@entry=52,
    check_complete=check_complete@entry=false) at
./build/../src/common/pg_lzcompress.c:767
#1  0x000055584c5906cb in toast_decompress_datum_slice (slicelength=52,
attr=0x55584d6c39a8)
    at ./build/../src/backend/access/common/detoast.c:483
#2  detoast_attr_slice (attr=<optimized out>,
sliceoffset=sliceoffset@entry=0, slicelength=52)
    at ./build/../src/backend/access/common/detoast.c:274
#3  0x000055584c9e6f2a in pg_detoast_datum_slice (datum=<optimized out>,
first=first@entry=0,
    count=<optimized out>) at
./build/../src/backend/utils/fmgr/fmgr.c:1754
#4  0x00007f0bc257a7c1 in geometry_geometrytype (fcinfo=0x55584d6bea60) at
lwgeom_ogc.c:199
#5  0x000055584c740c9e in ExecInterpExpr (state=0x55584d6be578,
econtext=0x55584d6be260,
    isnull=<optimized out>) at
./build/../src/backend/executor/execExprInterp.c:699
#6  0x000055584c74ec62 in ExecEvalExprSwitchContext (isNull=0x7ffec8369497,
econtext=0x55584d6be260,
    state=0x55584d6be578) at
./build/../src/include/executor/executor.h:313
#7  ExecProject (projInfo=0x55584d6be570) at
./build/../src/include/executor/executor.h:347
#8  ExecScan (node=<optimized out>, accessMtd=0x55584c773130 <SeqNext>,
    recheckMtd=0x55584c7731c0 <SeqRecheck>) at
./build/../src/backend/executor/execScan.c:238
#9  0x000055584c744bcd in ExecProcNode (node=0x55584d6be150)
    at ./build/../src/include/executor/executor.h:245
#10 ExecutePlan (execute_once=<optimized out>, dest=0x55584d6b8640,
direction=<optimized out>,
    numberTuples=0, sendTuples=<optimized out>, operation=CMD_SELECT,
    use_parallel_mode=<optimized out>, planstate=0x55584d6be150,
estate=0x55584d6bded8)
    at ./build/../src/backend/executor/execMain.c:1646


pgsql-bugs by date:

Previous
From: Max Vikharev
Date:
Subject: Re: BUG #16691: Autovacuum stops processing certain databases until postgresql rebooted
Next
From: Tom Lane
Date:
Subject: Re: BUG #16691: Autovacuum stops processing certain databases until postgresql rebooted