agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix memory leak in pgstat_progress_parallel_incr_param()
Date: Mon, 08 Jun 2026 06:29:51 +0000
Message-ID: <E1wWTUd-001Yb5-2r@gemulon.postgresql.org> (raw)

Fix memory leak in pgstat_progress_parallel_incr_param()

When called from a parallel worker, this function calls initStringInfo()
and pq_beginmessage(), causing a StringInfo allocation to happen twice.
pq_endmessage() frees only the second allocation, with each call leaking
~1 kB into the per-worker memory context.  This could cause a few
hundred megabytes worth of memory to pile up until the worker exits (the
message allocations happen in the parallel worker context), with the
situation being worse the longer a parallel worker runs.

Oversight in f1889729dd3.

Author: Baji Shaik <baji.pgdev@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/CA+fm-RMopta1Dmq8udiU5sp+zwTvhUf4+xfbr3rZDfczH+p-xw@mail.gmail.com
Backpatch-through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4154a148206375e4af136558953e78dd2a5398ef

Modified Files
--------------
src/backend/utils/activity/backend_progress.c | 2 --
1 file changed, 2 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1wWTUd-001Yb5-2r@gemulon.postgresql.org>
Permalink:  ../E1wWTUd-001Yb5-2r@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wWTUd-001Yb5-2r@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix memory leak in pgstat_progress_parallel_incr_param()
  In-Reply-To: <E1wWTUd-001Yb5-2r@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox