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: Avoid leaking memory during large-scale REASSIGN OWNED BY operat
Date: Wed, 01 Dec 2021 18:45:07 +0000
Message-ID: <E1msUbL-0007l9-MV@gemulon.postgresql.org> (raw)

Avoid leaking memory during large-scale REASSIGN OWNED BY operations.

The various ALTER OWNER routines tend to leak memory in
CurrentMemoryContext.  That's not a problem when they're only called
once per command; but in this usage where we might be touching many
objects, it can amount to a serious memory leak.  Fix that by running
each call in a short-lived context.

(DROP OWNED BY likely has a similar issue, except that you'll probably
run out of lock table space before noticing.  REASSIGN is worth fixing
since for most non-table object types, it won't take any lock.)

Back-patch to all supported branches.  Unfortunately, in the back
branches this helps to only a limited extent, since the sinval message
queue bloats quite a lot in this usage before commit 3aafc030a,
consuming memory more or less comparable to what's actually leaked.
Still, it's clearly a leak with a simple fix, so we might as well fix it.

Justin Pryzby, per report from Guillaume Lelarge

Discussion: https://postgr.es/m/CAECtzeW2DAoioEGBRjR=CzHP6TdL=yosGku8qZxfX9hhtrBB0Q@mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7413caabe66e02b8967825a2dc1041e9db246622

Modified Files
--------------
src/backend/catalog/pg_shdepend.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)



view thread (6+ messages)  latest in thread

Message-ID: <E1msUbL-0007l9-MV@gemulon.postgresql.org>
Permalink:  ../E1msUbL-0007l9-MV@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1msUbL-0007l9-MV@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: Avoid leaking memory during large-scale REASSIGN OWNED BY operat
  In-Reply-To: <E1msUbL-0007l9-MV@gemulon.postgresql.org>
  References: <E1msUbL-0007l9-MV@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