> src/test/regress/expected/numa.out       |  13 +++
> src/test/regress/expected/numa_1.out     |   5 +

numa_1.out is catching this error:

ERROR:  libnuma initialization failed or NUMA is not supported on this platform

This is what I'm getting when running PG18 in docker on Debian trixie
(libnuma 2.0.19).

However, on older distributions, the error is different:

postgres =# select * from pg_shmem_allocations_numa;
ERROR:  XX000: failed NUMA pages inquiry status: Operation not permitted
LOCATION:  pg_get_shmem_allocations_numa, shmem.c:691

This makes the numa regression tests fail in Docker on Debian bookworm
(libnuma 2.0.16) and older and all of the Ubuntu LTS releases.

The attached patch makes it accept these errors, but perhaps it would
be better to detect it in pg_numa_available().

Christoph
>From bfa516b8c68203df8dccab168a729dc9823045dd Mon Sep 17 00:00:00 2001
From: Christoph Berg <[email protected]>
Date: Thu, 16 Oct 2025 13:24:56 +0200
Subject: [PATCH] numa: Catch "Operation not permitted" error

On older (before 2.0.19) libnuma versions, the error thrown when the
NUMA status cannot be inquired is different.
---
 .../expected/pg_buffercache_numa_2.out        | 21 +++++++++++++++++++
 src/test/regress/expected/numa_2.out          |  9 ++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 contrib/pg_buffercache/expected/pg_buffercache_numa_2.out
 create mode 100644 src/test/regress/expected/numa_2.out

diff --git a/contrib/pg_buffercache/expected/pg_buffercache_numa_2.out b/contrib/pg_buffercache/expected/pg_buffercache_numa_2.out
new file mode 100644
index 00000000000..b970dd2eaf9
--- /dev/null
+++ b/contrib/pg_buffercache/expected/pg_buffercache_numa_2.out
@@ -0,0 +1,21 @@
+SELECT NOT(pg_numa_available()) AS skip_test \gset
+\if :skip_test
+\quit
+\endif
+-- We expect at least one entry for each buffer
+select count(*) >= (select setting::bigint
+                    from pg_settings
+                    where name = 'shared_buffers')
+from pg_buffercache_numa;
+ERROR:  failed NUMA pages inquiry: Operation not permitted
+-- Check that the functions / views can't be accessed by default. To avoid
+-- having to create a dedicated user, use the pg_database_owner pseudo-role.
+SET ROLE pg_database_owner;
+SELECT count(*) > 0 FROM pg_buffercache_numa;
+ERROR:  permission denied for view pg_buffercache_numa
+RESET role;
+-- Check that pg_monitor is allowed to query view / function
+SET ROLE pg_monitor;
+SELECT count(*) > 0 FROM pg_buffercache_numa;
+ERROR:  failed NUMA pages inquiry: Operation not permitted
+RESET role;
diff --git a/src/test/regress/expected/numa_2.out b/src/test/regress/expected/numa_2.out
new file mode 100644
index 00000000000..b4c19f01f59
--- /dev/null
+++ b/src/test/regress/expected/numa_2.out
@@ -0,0 +1,9 @@
+SELECT NOT(pg_numa_available()) AS skip_test \gset
+\if :skip_test
+SELECT COUNT(*) = 0 AS ok FROM pg_shmem_allocations_numa;
+\quit
+\endif
+-- switch to superuser
+\c -
+SELECT COUNT(*) >= 0 AS ok FROM pg_shmem_allocations_numa;
+ERROR:  failed NUMA pages inquiry status: Operation not permitted
-- 
2.51.0

Reply via email to