agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve pgstat_get_entry_ref_cached() behavior on out-of-memory
Date: Mon, 20 Jul 2026 06:52:32 +0000
Message-ID: <E1wlhrd-000EOz-0T@gemulon.postgresql.org> (raw)
Improve pgstat_get_entry_ref_cached() behavior on out-of-memory errors
A failure in allocating a new cache entry in the backend-level hash
table holding references to shared stats entries would leave the table
in an inconsistent state, crash or FATAL at session exit, depending on
if there are pending stats.
Rather than leaving things in an inconsistent state on OOM, the code is
switched to use MemoryContextAllocExtended(MCXT_ALLOC_NO_OOM), so as an
allocation failure leads to a cleanup of the hash table before issuing
the allocation error.
The problem is unlikely going to show up in practice, so no backpatch is
done. Note that shared memory is not impacted, only a backend-level
hash table.
Reported-by: Alex Masterov <amasterov@gmail.com>
Discussion: https://postgr.es/m/CA+8z=zumV9sscgK=j1Es+-564maVoO9CMDdB9CsW9=FCziCj3w@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/16ebc196d8926823bc8d64931557b679cecd67aa
Modified Files
--------------
src/backend/utils/activity/pgstat_shmem.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
Message-ID: <E1wlhrd-000EOz-0T@gemulon.postgresql.org>
Permalink: ../E1wlhrd-000EOz-0T@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wlhrd-000EOz-0T@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Improve pgstat_get_entry_ref_cached() behavior on out-of-memory
In-Reply-To: <E1wlhrd-000EOz-0T@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox