pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Berg <myon@debian.org>
Subject: [PATCH v2] Make pg_numa_init() cope with Docker
Date: Thu, 16 Oct 2025 13:24:56 +0200

In seccomp-restricted environments like Docker, numactl versions before
2.0.19 would not properly catch EPERM. As the numa_available()
implementation is very short, just inline in here with the proper fix.

Upstream fix: https://github.com/numactl/numactl/commit/0ab9c7a0d857bea1724139c48e2e58ed6a81647f
---
 src/port/pg_numa.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

inline patch 1: src/port/pg_numa.c (+11/-4 lines) download inline-1.patchdiff --git a/src/port/pg_numa.c b/src/port/pg_numa.c index 3368a43a338..932099be1e5 100644 --- a/src/port/pg_numa.c +++ b/src/port/pg_numa.c @@ -43,13 +43,20 @@ #define NUMA_QUERY_CHUNK_SIZE 1024 #endif -/* libnuma requires initialization as per numa(3) on Linux */ +/* + * libnuma requires initialization as per numa(3) on Linux. + * + * This should ideally just return numa_available(), but numactl versions + * before 2.0.19 ignored EPERM from get_mempolicy(), leading to ugly error + * messages when used in seccomp-restricted environments like Docker. We just + * inline the 2.0.19 version of numa_available() here. + */ int pg_numa_init(void) { - int r = numa_available(); - - return r; + if (get_mempolicy(NULL, NULL, 0, 0, 0) < 0 && (errno == ENOSYS || errno == EPERM)) + return -1; + return 0; } /* -- 2.39.5
--J3H232Pne8aWMmeW--

Message-ID: <no-message-id-442@localhost>
Permalink:  ../no-message-id-442@localhost/
Also on:    postgresql.org/message-id/no-message-id-442@localhost

 ·  · 

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: myon@debian.org
  Subject: Re: [PATCH v2] Make pg_numa_init() cope with Docker
  In-Reply-To: <no-message-id-442@localhost>

* 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