Re: pg_walinspect memory leaks
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Andres Freund <andres@anarazel.de>, Peter Geoghegan <pg@bowt.ie>, Jeff Davis <pgsql@j-davis.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-02-17T07:56:32Z
Lists: pgsql-hackers
On Thu, Feb 16, 2023 at 06:00:00PM +0530, Bharath Rupireddy wrote: > The memory usage goes up with many WAL records in GetWALRecordsInfo(). > The affected functions are pg_get_wal_records_info() and > pg_get_wal_records_info_till_end_of_wal(). I think the best way to fix > this is to use a temporary memory context (like the jsonfuncs.c), > reset it after every tuple is put into the tuple store. This fix keeps > the memory under limits. I'm attaching the patches here. What you are doing here looks OK, at quick glance. That's common across the code, see also dblink or file_fdw. > For HEAD, I'd > want to be a bit defensive and use the temporary memory context for > pg_get_wal_fpi_info() too. If there is a burst of FPWs across the range you are scanning, the problem could be equally worse. Sorry for missing that. -- Michael
Commits
-
Limit memory usage of pg_walinspect functions.
- da32a99df1f5 15.3 landed
- 69e8c7cf1dfa 16.0 landed