pgsql: Fix leaked hash scans in pg_listening_channels().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix leaked hash scans in pg_listening_channels().
Date: 2026-10-25 19:14:19
Message-ID: E1xL3ff-00000000jQj-2apP@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix leaked hash scans in pg_listening_channels().

Commit 282b1cde9 changed pg_listening_channels() to keep a hash table
scan open between calls of this set-returning function. If the
executor stops fetching rows early, as with a target-list call under
LIMIT, the scan remains registered until transaction end, resulting in
leak complaints and eventually a PANIC.

Instead materialize the result in a tuplestore, so that we can
complete the hash scan within a single call.

Author: Joel Jacobson <joel(at)compiler(dot)org>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/069fc976-bee1-4f0f-b22b-86ef7ed4f9ff@app.fastmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b491ff1cd2e23ac7a9f9efbd59ddd4aa02dbb58

Modified Files
--------------
src/backend/commands/async.c | 56 ++++++++++++++-----------------------
src/test/regress/expected/async.out | 7 +++++
src/test/regress/sql/async.sql | 4 +++
3 files changed, 32 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-25 22:19:01 pgsql: Fix "variable set but not used" warning with unnamed POSIX semap
Previous Message Peter Eisentraut 2026-10-25 11:59:39 pgsql: Add pg_attribute_counted_by() to various flexible array members