Re: To Tomas Vondra > So maybe PG should implement numa_available itself like that.
Following our discussion at pgconf.eu last week, I just implemented that. The numa and pg_buffercache tests pass in Docker on Debian bookworm now. Christoph
>From 0b0088145b42a4316fb15a0ea4363bbebfabdfd7 Mon Sep 17 00:00:00 2001 From: Christoph Berg <[email protected]> Date: Thu, 16 Oct 2025 13:24:56 +0200 Subject: [PATCH v2] Make pg_numa_init() cope with Docker 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(-) diff --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
