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 09:05 Daniel Gustafsson <[email protected]>
  2026-03-27 11:13 ` Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding Heikki Linnakangas <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

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

> On 27 Mar 2026, at 09:59, Heikki Linnakangas <[email protected]> wrote:

> Hmm, perhaps. But there's a simpler, less invasive fix. When that code was written, we didn't have MCXT_ALLOC_HUGE nor MCXT_ALLOC_NO_OOM. Now that we do, we can just use palloc_extended(MCXT_ALLOC_HUGE | MCXT_ALLOC_NO_OOM) instead of raw malloc(). Per attached.

LGTM.

--
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 09:05 Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding Daniel Gustafsson <[email protected]>
@ 2026-03-27 11:13 ` Heikki Linnakangas <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

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

On 27/03/2026 11:05, Daniel Gustafsson wrote:
>> On 27 Mar 2026, at 09:59, Heikki Linnakangas <[email protected]> wrote:
> 
>> Hmm, perhaps. But there's a simpler, less invasive fix. When that code was written, we didn't have MCXT_ALLOC_HUGE nor MCXT_ALLOC_NO_OOM. Now that we do, we can just use palloc_extended(MCXT_ALLOC_HUGE | MCXT_ALLOC_NO_OOM) instead of raw malloc(). Per attached.
> 
> LGTM.

Committed, thanks!


Here's one way to reproduce the invalid encoding error without 
artificially corrupting the file:

-- Run a query with a non-latin character in it. (This needs to be run 
in UTF-8 database.)
psql postgres -c 'select g as "omega Ω col" from generate_series(1, 1) g;'

-- Create a database with latin1 encoding
psql postgres -c "create database latindb encoding 'latin1' lc_ctype='C' 
lc_collate='C' template template0"

-- check pg_stat_statements() from the latin1 database
-- This fails with encoding conversion error.
PATH=~/pgsql.fsmfork/bin/ psql latindb -c "create extension 
pg_stat_statements; select * from pg_stat_statements"

If you repeat the erroring "select * from pg_stat_statements" in latindb 
many times, you can see the memory usage grow without this fix.

- Heikki







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


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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-27 09:05 Re: Memory leak in pg_stat_statements when qtext file contains invalid encoding Daniel Gustafsson <[email protected]>
2026-03-27 11:13 ` Heikki Linnakangas <[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