Re: [PATCH] nodeindexscan with reorder memory leak
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aliaksandr Kalenik <akalenik@kontur.io>
Cc: pgsql-hackers@lists.postgresql.org, Heikki Linnakangas <hlinnaka@iki.fi>,
Alexander Korotkov <aekorotkov@gmail.com>
Date: 2022-01-30T16:24:35Z
Lists: pgsql-hackers
Attachments
- failing-test-case.patch (text/x-diff) patch
Aliaksandr Kalenik <akalenik@kontur.io> writes: > 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]: > ... > 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. Actually, that code has got worse problems than that. I tried to improve our regression tests to exercise that code path, as attached. What I got was +SELECT point(x,x), (SELECT circle_center(f1) FROM gcircle_tbl ORDER BY f1 <-> p oint(x,x) LIMIT 1) as c FROM generate_series(0,1000,1) x; +ERROR: index returned tuples in wrong order (The error doesn't always appear depending on what generate_series parameters you use, but it seems to show up consistently with a step of 1 and a limit of 1000 or more.) Fixing this is well beyond my knowledge of that code, so I'm punting it to the original authors. regards, tom lane
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