pg_walinspect memory leaks
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>,
Jeff Davis <pgsql@j-davis.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-02-13T23:22:02Z
Lists: pgsql-hackers
It looks like pg_walinspect's GetWALRecordsInfo() routine doesn't take sufficient care with memory management. It should avoid memory leaks of the kind that lead to OOMs whenever pg_get_wal_records_info_till_end_of_wal() has to return very many tuples. Right now it isn't that hard to make that happen, even on a system where memory is plentiful. I wasn't expecting that, because all of these functions use a tuplestore. More concretely, it looks like GetWALRecordInfo() calls CStringGetTextDatum/cstring_to_text in a way that accumulates way too much memory in ExprContext. This could be avoided by using a separate memory context that is reset periodically, or something else along the same lines. -- Peter Geoghegan
Commits
-
Limit memory usage of pg_walinspect functions.
- da32a99df1f5 15.3 landed
- 69e8c7cf1dfa 16.0 landed