[PATCH] nodeindexscan with reorder memory leak
Aliaksandr Kalenik <akalenik@kontur.io>
From: Aliaksandr Kalenik <akalenik@kontur.io>
To: pgsql-hackers@lists.postgresql.org
Date: 2022-01-30T02:49:34Z
Lists: pgsql-hackers
Attachments
- 0001-nodeindexscan_with_reorder_memory_leak.patch (application/octet-stream) patch 0001
Hey! I was investigating a leak reported in the PostGIS issues tracker [1] which led me to the Postgres side where the problem really is. The leak is reproducible with query from original ticket [1]: WITH latitudes AS ( SELECT generate_series AS latitude FROM generate_series(-90, 90, 0.1) ), longitudes AS ( SELECT generate_series AS longitude FROM generate_series(-180, 180, 0.1) ), points AS ( SELECT ST_SetSRID(ST_Point(longitude, latitude), 4326)::geography AS geog FROM latitudes CROSS JOIN longitudes ) SELECT geog, ( SELECT name FROM ne_110m_admin_0_countries AS ne ORDER BY p.geog <-> ne.geog LIMIT 1 ) FROM points AS p ; The leak is only noticeable when index scan with reorder happens as part of subquery plan which is explained by the fact that heap tuples cloned in reorderqueue_push are not freed during flush of reorder queue in ExecReScanIndex. [1] https://trac.osgeo.org/postgis/ticket/4720
Commits
-
Fix memory leak in IndexScan node with reordering
- 3f74daa8dfc6 15.0 landed
- 2e9033a54804 10.21 landed
- 0d554775bd04 11.16 landed
- 7a12a9e3cc97 12.11 landed
- ac2303aa0386 13.7 landed
- c76665edce3d 14.3 landed