pg_walinspect memory leaks

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: pg_walinspect memory leaks
Date: 2023-02-13 23:22:02
Message-ID: CAH2-WznLEJjn7ghmKOABOEZYuJvkTk=GKU3m0+-XBAH+erPiJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2023-02-13 23:22:11 [PATCH] Fix unbounded authentication exchanges during PQconnectPoll()
Previous Message Nathan Bossart 2023-02-13 22:56:47 Re: recovery modules