pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle ENOENT status when querying NUMA node
Date: Mon, 26 Jan 2026 23:22:31 +0000
Message-ID: <E1vkVuh-002rCP-0M@gemulon.postgresql.org> (raw)

Handle ENOENT status when querying NUMA node

We've assumed that touching the memory is sufficient for a page to be
located on one of the NUMA nodes. But a page may be moved to a swap
after we touch it, due to memory pressure.

We touch the memory before querying the status, but there is no
guarantee it won't be moved to the swap in the meantime. The touching
happens only on the first call, so later calls are more likely to be
affected. And the batching increases the window too.

It's up to the kernel if/when pages get moved to swap. We have to accept
ENOENT (-2) as a valid result, and handle it without failing. This patch
simply treats it as an unknown node, and returns NULL in the two
affected views (pg_shmem_allocations_numa and pg_buffercache_numa).

Hugepages cannot be swapped out, so this affects only regular pages.

Reported by Christoph Berg, investigation and fix by me. Backpatch to
18, where the two views were introduced.

Reported-by: Christoph Berg <myon@debian.org>
Discussion: 18
Backpatch-through: https://postgr.es/m/aTq5Gt_n-oS_QSpL@msg.df7cb.de

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9796c4f5607be5807f2d2ba9bca1bc87af198db3

Modified Files
--------------
contrib/pg_buffercache/pg_buffercache_pages.c | 12 ++++++++--
src/backend/storage/ipc/shmem.c               | 32 +++++++++++++++++++++------
2 files changed, 35 insertions(+), 9 deletions(-)



view thread (2+ messages)

Message-ID: <E1vkVuh-002rCP-0M@gemulon.postgresql.org>
Permalink:  ../E1vkVuh-002rCP-0M@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vkVuh-002rCP-0M@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: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Handle ENOENT status when querying NUMA node
  In-Reply-To: <E1vkVuh-002rCP-0M@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox