Re: [PATCH] Fix memory leak in pgstat_progress_parallel_incr_param()

From: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
To: Tristan Partin <tristan(at)partin(dot)io>
Cc: bertranddrouvot(dot)pg(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Fix memory leak in pgstat_progress_parallel_incr_param()
Date: 2026-06-05 23:44:59
Message-ID: CA+fm-RMwUuX7SimgfHZ1o3=RYWQT7wC+KC2+uAgbPqHij25mug@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 5, 2026 at 4:29 PM Tristan Partin <tristan(at)partin(dot)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

Attachment Content-Type Size
0001-Fix-memory-leak-in-pgstat_progress_parallel_incr_par.patch application/octet-stream 1.5 KB
0002-Allocate-progress-message-buffer-once-per-parallel-w.patch application/octet-stream 2.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-06 00:16:02 Re: Fix OAuth validator docs for error_detail on internal errors
Previous Message Jelte Fennema-Nio 2026-06-05 22:24:48 Re: alert clients when prepared statements are deallocated