]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix memory leak in pgstat_progress_parallel_incr_param()
authorMichael Paquier <michael@paquier.xyz>
Mon, 8 Jun 2026 06:29:21 +0000 (15:29 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 8 Jun 2026 06:29:21 +0000 (15:29 +0900)
commit8ad4148313d42a6d260c5c63f295bf3a22dae252
tree7ab6cfe024d63fc66fac35f0e1e34cb7e0ac55ae
parentefd885d05b8beded386fbb5a9d737dc9e65289a9
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
src/backend/utils/activity/backend_progress.c