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 <[email protected]>
Reviewed-by: Sami Imseih <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Discussion: 
https://postgr.es/m/ca+fm-rmopta1dmq8udiu5sp+zwtvhuf4+xfbr3rzdfczh+p...@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(-)

Reply via email to