pgsql: Fix snapshot leak warning for some procedures - Mailing list pgsql-committers

From Peter Eisentraut
Subject pgsql: Fix snapshot leak warning for some procedures
Date
Msg-id E1fuOZl-0006vO-PB@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7a3b7bbfded3142aaa8edae2dbc88999568cc1cd

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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix missing dependency for pg_dump's ENABLE ROW LEVEL SECURITYi
Next
From: Thomas Munro
Date:
Subject: pgsql: Code review for simplehash.h.