Re: [PATCH] Fix memory leak in pgstat_progress_parallel_incr_param()
Baji Shaik <baji.pgdev@gmail.com>
From: Baji Shaik <baji.pgdev@gmail.com>
To: Tristan Partin <tristan@partin.io>
Cc: bertranddrouvot.pg@gmail.com, pgsql-hackers@lists.postgresql.org
Date: 2026-06-05T23:44:59Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-memory-leak-in-pgstat_progress_parallel_incr_par.patch (application/octet-stream) patch 0001
- 0002-Allocate-progress-message-buffer-once-per-parallel-w.patch (application/octet-stream) patch 0002
On Fri, Jun 5, 2026 at 4:29 PM Tristan Partin <tristan@partin.io> wrote:
> This looks pretty reasonable to me. Nice find. Did you think about
> keeping the code path as is and just removing the first initStringInfo()
> call? Removing the allocation per progress message seems like a good
> idea to me. Maybe you could separate this change into two patches. One
> to fix the memory leak and another to remove the allocation per message.
> A committer could then decide for themselves if the second patch is
> worth committing.
>
Thank you for the review. I hadn't thought of splitting it, but it's
a good idea. I see f1889729dd3 itself is in PG17+, so the bug fix is
a backport candidate independently of the PG19 caller bb8dff9995f.
Patches attached:
0001: drop the redundant initStringInfo() call (backport candidate)
0002: allocate the static buffer once per process via
pq_beginmessage_reuse / pq_endmessage_reuse, to avoid the
per-call allocation (master only)
Thanks,
Baji Shaik
Commits
-
Fix memory leak in pgstat_progress_parallel_incr_param()
- 8ad4148313d4 17 (unreleased) landed
- 4154a1482063 18 (unreleased) landed
- b20c952ce703 19 (unreleased) landed