public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding
2+ messages / 2 participants
[nested] [flat]

* Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding
@ 2026-03-27 08:51  Daniel Gustafsson <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Daniel Gustafsson @ 2026-03-27 08:51 UTC (permalink / raw)
  To: Lukas Fittl <[email protected]>; +Cc: Gaurav Singh <[email protected]>; [email protected]

> On 27 Mar 2026, at 09:21, Lukas Fittl <[email protected]> wrote:

> But I think you're correct about qbuffer - because that buffer is
> using malloc (not palloc), its not part of any memory context, and so
> it will happily leak on abort.
> 
> It appears our use of malloc in pg_stat_statements is so that we can
> fail on OOM and return NULL without a jump. I think that makes sense
> for when a GC cycle was triggered during regular query execution
> (since we don't want to error the original query), but it seems like
> just bubbling up the OOM if needed when querying the
> pg_stat_statements function seems fine.

We could also use palloc_extended() with MCXT_ALLOC_NO_OOM to avoid erroring
out on OOM and be able to return NULL?

--
Daniel Gustafsson







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

* Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding
@ 2026-03-27 08:57  Gaurav Singh <[email protected]>
  parent: Daniel Gustafsson <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Gaurav Singh @ 2026-03-27 08:57 UTC (permalink / raw)
  To: [email protected]; +Cc: Lukas Fittl <[email protected]>; [email protected]

> We could also use palloc_extended() with MCXT_ALLOC_NO_OOM to avoid
erroring
> out on OOM and be able to return NULL?

Oh, it seems palloc_extended() would be a better fix.


--
Gaurav


On Fri, Mar 27, 2026 at 2:21 PM Daniel Gustafsson <[email protected]> wrote:

> > On 27 Mar 2026, at 09:21, Lukas Fittl <[email protected]> wrote:
>
> > But I think you're correct about qbuffer - because that buffer is
> > using malloc (not palloc), its not part of any memory context, and so
> > it will happily leak on abort.
> >
> > It appears our use of malloc in pg_stat_statements is so that we can
> > fail on OOM and return NULL without a jump. I think that makes sense
> > for when a GC cycle was triggered during regular query execution
> > (since we don't want to error the original query), but it seems like
> > just bubbling up the OOM if needed when querying the
> > pg_stat_statements function seems fine.
>
> We could also use palloc_extended() with MCXT_ALLOC_NO_OOM to avoid
> erroring
> out on OOM and be able to return NULL?
>
> --
> Daniel Gustafsson
>
>


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


end of thread, other threads:[~2026-03-27 08:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-27 08:51 Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding Daniel Gustafsson <[email protected]>
2026-03-27 08:57 ` Gaurav Singh <[email protected]>

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