pgsql: Fix shmem allocation of fixed-sized custom stats kind

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix shmem allocation of fixed-sized custom stats kind
Date: 2026-04-07 03:01:21
Message-ID: E1w9wgq-003KJo-1h@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix shmem allocation of fixed-sized custom stats kind

StatsShmemSize(), that computes the shmem size needed for pgstats,
includes the amount of shared memory wanted by all the custom stats
kinds registered. However, the shared memory allocation was done by
ShmemAlloc() in StatsShmemInit(), meaning that the space reserved was
not used, wasting some memory.

These extra allocations would show up under "<anonymous>" in
pg_shmem_allocations, as the allocations done by ShmemAlloc() are not
tracked by ShmemIndexEnt.

Issue introduced by 7949d9594582.

Author: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Discussion: https://postgr.es/m/04b04387-92f5-476c-90b0-4064e71c5f37@iki.fi
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/17132f55c5a2c04743edec20655cc7123ce08713

Modified Files
--------------
src/backend/utils/activity/pgstat_shmem.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-04-07 03:04:12 Re: pgsql: Reduce log level of some logical decoding messages from LOG to D
Previous Message Amit Langote 2026-04-07 01:48:40 pgsql: Fix deferred FK check batching introduced by commit b7b27eb41a5