pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Prevent long-term memory leakage in autovacuum launcher.
Date: Wed, 31 Aug 2022 20:23:49 +0000
Message-ID: <E1oTUFZ-000o2M-B2@gemulon.postgresql.org> (raw)

Prevent long-term memory leakage in autovacuum launcher.

get_database_list() failed to restore the caller's memory context,
instead leaving current context set to TopMemoryContext which is
how CommitTransactionCommand() leaves it.  The callers both think
they are using short-lived contexts, for the express purpose of
not having to worry about cleaning up individual allocations.
The net effect therefore is that supposedly short-lived allocations
could accumulate indefinitely in the launcher's TopMemoryContext.

Although this has been broken for a long time, it seems we didn't
have any obvious memory leak here until v15's rearrangement of the
stats logic.  I (tgl) am not entirely convinced that there's no
other leak at all, though, and we're surely at risk of adding one
in future back-patched fixes.  So back-patch to all supported
branches, even though this may be only a latent bug in pre-v15.

Reid Thompson

Discussion: https://postgr.es/m/972a4e12b68b0f96db514777a150ceef7dcd2e0f.camel@crunchydata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1c1294be716d96e804aadafc249fcbfa8367621d

Modified Files
--------------
src/backend/postmaster/autovacuum.c | 3 +++
1 file changed, 3 insertions(+)



view thread (7+ messages)

Message-ID: <E1oTUFZ-000o2M-B2@gemulon.postgresql.org>
Permalink:  ../E1oTUFZ-000o2M-B2@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oTUFZ-000o2M-B2@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Prevent long-term memory leakage in autovacuum launcher.
  In-Reply-To: <E1oTUFZ-000o2M-B2@gemulon.postgresql.org>
  References: <E1oTUFZ-000o2M-B2@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox