From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix snapshot reference leak if lo_export fails.
Date: Wed, 03 Nov 2021 09:44:21 +0000
Message-ID: <E1miCof-0006bu-Dw@gemulon.postgresql.org> (raw)
Fix snapshot reference leak if lo_export fails.
If lo_export() fails to open the target file or to write to it, it leaks
the created LargeObjectDesc and its snapshot in the top-transaction
context and resource owner. That's pretty harmless, it's a small leak
after all, but it gives the user a "Snapshot reference leak" warning.
Fix by using a short-lived memory context and no resource owner for
transient LargeObjectDescs that are opened and closed within one function
call. The leak is easiest to reproduce with lo_export() on a directory
that doesn't exist, but in principle the other lo_* functions could also
fail.
Backpatch to all supported versions.
Reported-by: Andrew B
Reviewed-by: Alvaro Herrera
Discussion: https://www.postgresql.org/message-id/32bf767a-2d65-71c4-f170-122f416bab7e@iki.fi
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/4ebd740cd3f3afe5523c5947be836edf8cccdc27
Modified Files
--------------
src/backend/libpq/be-fsstubs.c | 146 ++++++++++++++---------------
src/backend/storage/large_object/inv_api.c | 27 +++---
src/test/regress/input/largeobject.source | 11 +++
src/test/regress/output/largeobject.source | 11 +++
4 files changed, 104 insertions(+), 91 deletions(-)
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: heikki.linnakangas@iki.fi
Subject: Re: pgsql: Fix snapshot reference leak if lo_export fails.
In-Reply-To: <E1miCof-0006bu-Dw@gemulon.postgresql.org>
References: <E1miCof-0006bu-Dw@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