pgsql: Limit memory usage of pg_walinspect functions.

From: Jeff Davis <jdavis(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Limit memory usage of pg_walinspect functions.
Date: 2023-02-20 19:29:05
Message-ID: E1pUBqS-0028Cn-PG@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Limit memory usage of pg_walinspect functions.

GetWALRecordsInfo() and pg_get_wal_fpi_info() can leak memory across
WAL record iterations. Fix this by using a temporary memory context
that's reset for each WAL record iteraion.

Also a use temporary context for loops in GetXLogSummaryStats(). The
number of iterations is a small constant, so the previous behavior was
not a leak, but fix for clarity (but no need to backport).

Backport GetWALRecordsInfo() change to version
15. pg_get_wal_fpi_info() didn't exist in version 15.

Reported-by: Peter Geoghegan
Author: Bharath Rupireddy
Discussion: https://www.postgresql.org/message-id/CAH2-WznLEJjn7ghmKOABOEZYuJvkTk%3DGKU3m0%2B-XBAH%2BerPiJQ%40mail.gmail.com
Backpatch-through: 15

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/69e8c7cf1dfa08ae099c33d0d371ad69d405903d

Modified Files
--------------
contrib/pg_walinspect/pg_walinspect.c | 58 ++++++++++++++++++++++++++++++++---
1 file changed, 53 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2023-02-20 19:29:57 pgsql: Limit memory usage of pg_walinspect functions.
Previous Message Tom Lane 2023-02-20 17:06:42 pgsql: Remove gratuitous assumptions about what make_modifytable can se