From: Peter Eisentraut <peter_e@gmx.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix snapshot leak warning for some procedures
Date: Mon, 27 Aug 2018 20:57:29 +0000
Message-ID: <E1fuOZl-0006vP-PJ@gemulon.postgresql.org> (raw)
Fix snapshot leak warning for some procedures
The problem arises with the combination of CALL with output parameters
and doing a COMMIT inside the procedure. When a CALL has output
parameters, the portal uses the strategy PORTAL_UTIL_SELECT instead of
PORTAL_MULTI_QUERY. Using PORTAL_UTIL_SELECT causes the portal's
snapshot to be registered with the current resource
owner (portal->holdSnapshot); see
9ee1cf04ab6bcefe03a11837b53f29ca9dc24c7a for the reason.
Normally, PortalDrop() unregisters the snapshot. If not, then
ResourceOwnerRelease() will print a warning about a snapshot leak on
transaction commit. A transaction commit normally drops all
portals (PreCommit_Portals()), except the active portal. So in case of
the active portal, we need to manually release the snapshot to avoid the
warning.
Reported-by: Prabhat Sahu <prabhat.sahu@enterprisedb.com>
Reviewed-by: Jonathan S. Katz <jkatz@postgresql.org>
Branch
------
REL_11_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2657d4ea66c775c3334181722115be2d6128c5cd
Modified Files
--------------
src/backend/utils/mmgr/portalmem.c | 14 ++++++++--
.../plpgsql/src/expected/plpgsql_transaction.out | 30 ++++++++++++++++++++++
src/pl/plpgsql/src/sql/plpgsql_transaction.sql | 25 ++++++++++++++++++
3 files changed, 67 insertions(+), 2 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: peter_e@gmx.net
Subject: Re: pgsql: Fix snapshot leak warning for some procedures
In-Reply-To: <E1fuOZl-0006vP-PJ@gemulon.postgresql.org>
References: <E1fuOZl-0006vP-PJ@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