Re: [PATCH] Fix memory leak in pgstat_progress_parallel_incr_param() - Mailing list pgsql-hackers

From Baji Shaik
Subject Re: [PATCH] Fix memory leak in pgstat_progress_parallel_incr_param()
Date
Msg-id CA+fm-RMwUuX7SimgfHZ1o3=RYWQT7wC+KC2+uAgbPqHij25mug@mail.gmail.com
Whole thread
Responses Re: [PATCH] Fix memory leak in pgstat_progress_parallel_incr_param()
List pgsql-hackers
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
Attachment

pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: alert clients when prepared statements are deallocated
Next
From: Chao Li
Date:
Subject: Re: Fix OAuth validator docs for error_detail on internal errors