agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Fix memory leak in pgstat_progress_parallel_incr_param()
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix memory leak in pgstat_progress_parallel_incr_param()
@ 2026-06-08 06:29 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-06-08 06:29 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b20c952ce70370b22ea7a206d7b674a322397d28

Modified Files
--------------
src/backend/utils/activity/backend_progress.c | 2 --
1 file changed, 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix memory leak in pgstat_progress_parallel_incr_param()
@ 2026-06-08 06:29 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-06-08 06:29 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix memory leak in pgstat_progress_parallel_incr_param()
@ 2026-06-08 06:29 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-06-08 06:29 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8ad4148313d42a6d260c5c63f295bf3a22dae252

Modified Files
--------------
src/backend/utils/activity/backend_progress.c | 2 --
1 file changed, 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-06-08 06:29 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-08 06:29 pgsql: Fix memory leak in pgstat_progress_parallel_incr_param() Michael Paquier <michael@paquier.xyz>
2026-06-08 06:29 pgsql: Fix memory leak in pgstat_progress_parallel_incr_param() Michael Paquier <michael@paquier.xyz>
2026-06-08 06:29 pgsql: Fix memory leak in pgstat_progress_parallel_incr_param() Michael Paquier <michael@paquier.xyz>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox