=== Applying patches on top of PostgreSQL commit ID 5310fac6e0fcb1c7fcefb3446767673f9107328c === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Nov 6 23:06:25 UTC 2025 On branch cf/6049 nothing to commit, working tree clean === using 'git am' to apply patch ./v20251101-0001-Infrastructure-for-partitioning-shared-buf.patch === Applying: Infrastructure for partitioning shared buffers === using 'git am' to apply patch ./v20251101-0002-clock-sweep-basic-partitioning.patch === Applying: clock-sweep: basic partitioning === using 'git am' to apply patch ./v20251101-0003-clock-sweep-balancing-of-allocations.patch === Applying: clock-sweep: balancing of allocations === using 'git am' to apply patch ./v20251101-0004-clock-sweep-scan-all-partitions.patch === Applying: clock-sweep: scan all partitions === using 'git am' to apply patch ./v20251101-0005-clock-sweep-weighted-balancing.patch === Applying: clock-sweep: weighted balancing === using 'git am' to apply patch ./v20251101-0006-NUMA-shared-buffers-partitioning.patch === Applying: NUMA: shared buffers partitioning error: sha1 information is lacking or useless (contrib/pg_buffercache/pg_buffercache_pages.c). error: could not build fake ancestor hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 NUMA: shared buffers partitioning When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v20251101-0006-NUMA-shared-buffers-partitioning.patch === patching file contrib/pg_buffercache/pg_buffercache--1.6--1.7.sql patching file contrib/pg_buffercache/pg_buffercache_pages.c Hunk #1 succeeded at 813 (offset -1 lines). Hunk #2 succeeded at 851 (offset -1 lines). Hunk #3 succeeded at 871 (offset -1 lines). Hunk #4 succeeded at 889 (offset -1 lines). patching file src/backend/storage/buffer/buf_init.c patching file src/backend/storage/buffer/freelist.c Hunk #3 succeeded at 1006 (offset 1 line). Hunk #4 succeeded at 1033 (offset 1 line). Hunk #5 succeeded at 1078 (offset 1 line). Hunk #6 succeeded at 1088 (offset 1 line). Hunk #7 succeeded at 1125 (offset 1 line). patching file src/backend/utils/misc/guc_parameters.dat Hunk #1 succeeded at 2794 with fuzz 1 (offset 1888 lines). patching file src/backend/utils/misc/guc_tables.c patching file src/include/port/pg_numa.h patching file src/include/storage/buf_internals.h Hunk #1 succeeded at 299 (offset 24 lines). Hunk #2 succeeded at 312 (offset 24 lines). Hunk #3 succeeded at 555 (offset 65 lines). patching file src/include/storage/bufmgr.h patching file src/include/utils/guc_hooks.h patching file src/port/pg_numa.c [cf/6049 e1fc5c901f6] NUMA: shared buffers partitioning Author: Tomas Vondra Date: Wed Oct 29 21:41:26 2025 +0100 11 files changed, 736 insertions(+), 68 deletions(-) === using 'git am' to apply patch ./v20251101-0007-NUMA-partition-PGPROC.patch === fatal: previous rebase directory .git/rebase-apply still exists but mbox given. === using patch(1) to apply patch ./v20251101-0007-NUMA-partition-PGPROC.patch === patching file contrib/pg_buffercache/pg_buffercache--1.6--1.7.sql patching file contrib/pg_buffercache/pg_buffercache_pages.c Hunk #4 succeeded at 934 (offset -1 lines). patching file src/backend/access/transam/clog.c Hunk #1 succeeded at 575 (offset 1 line). Hunk #2 succeeded at 634 (offset 1 line). patching file src/backend/access/transam/twophase.c patching file src/backend/postmaster/launch_backend.c patching file src/backend/postmaster/pgarch.c patching file src/backend/postmaster/walsummarizer.c patching file src/backend/storage/buffer/buf_init.c patching file src/backend/storage/buffer/freelist.c patching file src/backend/storage/ipc/procarray.c patching file src/backend/storage/lmgr/lock.c patching file src/backend/storage/lmgr/proc.c Hunk #1 FAILED at 29. Hunk #2 succeeded at 77 (offset 1 line). Hunk #3 succeeded at 91 (offset 1 line). Hunk #4 succeeded at 124 (offset 1 line). Hunk #5 succeeded at 183 (offset 1 line). Hunk #6 FAILED at 247. Hunk #7 succeeded at 300 (offset 2 lines). Hunk #8 succeeded at 319 (offset 2 lines). Hunk #9 succeeded at 336 (offset 2 lines). Hunk #10 succeeded at 360 (offset 2 lines). Hunk #11 succeeded at 499 with fuzz 2 (offset 5 lines). Hunk #12 succeeded at 647 (offset 5 lines). Hunk #13 succeeded at 713 (offset 5 lines). Hunk #14 succeeded at 968 (offset 5 lines). Hunk #15 succeeded at 1376 (offset 10 lines). Hunk #16 succeeded at 1425 (offset 10 lines). Hunk #17 succeeded at 2315 (offset 10 lines). Hunk #18 succeeded at 2390 (offset 10 lines). 2 out of 18 hunks FAILED -- saving rejects to file src/backend/storage/lmgr/proc.c.rej patching file src/include/port/pg_numa.h patching file src/include/storage/proc.h patching file src/tools/pgindent/typedefs.list Hunk #1 succeeded at 1881 (offset 3 lines). Unstaged changes after reset: M contrib/pg_buffercache/pg_buffercache--1.6--1.7.sql M contrib/pg_buffercache/pg_buffercache_pages.c M src/backend/access/transam/clog.c M src/backend/access/transam/twophase.c M src/backend/postmaster/launch_backend.c M src/backend/postmaster/pgarch.c M src/backend/postmaster/walsummarizer.c M src/backend/storage/buffer/buf_init.c M src/backend/storage/buffer/freelist.c M src/backend/storage/ipc/procarray.c M src/backend/storage/lmgr/lock.c M src/backend/storage/lmgr/proc.c M src/include/port/pg_numa.h M src/include/storage/proc.h M src/tools/pgindent/typedefs.list Removing src/backend/storage/lmgr/proc.c.rej === using 'git apply' to apply patch ./v20251101-0007-NUMA-partition-PGPROC.patch === Applied patch to 'contrib/pg_buffercache/pg_buffercache--1.6--1.7.sql' cleanly. error: repository lacks the necessary blob to perform 3-way merge. Falling back to direct application... Applied patch to 'src/backend/access/transam/clog.c' cleanly. Applied patch to 'src/backend/access/transam/twophase.c' cleanly. Applied patch to 'src/backend/postmaster/launch_backend.c' cleanly. Applied patch to 'src/backend/postmaster/pgarch.c' cleanly. Applied patch to 'src/backend/postmaster/walsummarizer.c' cleanly. Applied patch to 'src/backend/storage/buffer/buf_init.c' cleanly. error: repository lacks the necessary blob to perform 3-way merge. Falling back to direct application... Applied patch to 'src/backend/storage/ipc/procarray.c' cleanly. Applied patch to 'src/backend/storage/lmgr/lock.c' cleanly. Applied patch to 'src/backend/storage/lmgr/proc.c' with conflicts. Applied patch to 'src/include/port/pg_numa.h' cleanly. Applied patch to 'src/include/storage/proc.h' cleanly. error: repository lacks the necessary blob to perform 3-way merge. Falling back to direct application... U src/backend/storage/lmgr/proc.c diff --cc src/backend/storage/lmgr/proc.c index 1504fafe6d8,cd938adbc33..00000000000 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@@ -36,9 -45,9 +45,10 @@@ #include "access/transam.h" #include "access/twophase.h" #include "access/xlogutils.h" +#include "access/xlogwait.h" #include "miscadmin.h" #include "pgstat.h" + #include "port/pg_numa.h" #include "postmaster/autovacuum.h" #include "replication/slotsync.h" #include "replication/syncrep.h" @@@ -145,9 -265,9 +266,10 @@@ ProcGlobalShmemSize(void size = add_size(size, sizeof(PROC_HDR)); size = add_size(size, sizeof(slock_t)); + size = add_size(size, PGSemaphoreShmemSize(ProcGlobalSemas())); size = add_size(size, PGProcShmemSize()); size = add_size(size, FastPathLockShmemSize()); + size = add_size(size, PGProcPartitionsShmemSize()); return size; } @@@ -288,27 -509,92 +511,99 @@@ InitProcGlobal(void /* For asserts checking we did not overflow. */ fpEndPtr = fpPtr + requestSize; ++<<<<<<< ours + /* Reserve space for semaphores. */ + PGReserveSemaphores(ProcGlobalSemas()); + + for (i = 0; i < TotalProcs; i++) ++======= + /* + * Mimic the logic we used to partition PGPROC entries. + */ + + /* + * If NUMA partitioning is enabled, and we decided we actually can do the + * partitioning, allocate the chunks. + * + * Otherwise we'll allocate a single array for everything. It's not quite + * what we did without NUMA, because there's an extra level of + * indirection, but it's the best we can do. + */ + if (((numa_flags & NUMA_PROCS) != 0) && numa_can_partition) ++>>>>>>> theirs { - PGPROC *proc = &procs[i]; + int node_procs; + int total_procs = 0; - /* Common initialization for all PGPROCs, regardless of type. */ + Assert(numa_procs_per_node > 0); + + /* build PGPROC entries for NUMA nodes */ + for (i = 0; i < numa_nodes; i++) + { + /* the last NUMA node may get fewer PGPROC entries, but meh */ + node_procs = Min(numa_procs_per_node, MaxBackends - total_procs); + + /* make sure to align the PGPROC array to memory page */ + fpPtr = (char *) TYPEALIGN(numa_page_size, fpPtr); + + /* remember this pointer too */ + partitions[i].fastpath_ptr = fpPtr; + Assert(node_procs == partitions[i].num_procs); + + fpPtr = fastpath_partition_init(fpPtr, node_procs, total_procs, i, + fpLockBitsSize, fpRelIdSize); + + total_procs += node_procs; + + /* don't overflow the allocation */ + Assert(fpPtr <= fpEndPtr); + } + + Assert(total_procs == MaxBackends); /* - * Set the fast-path lock arrays, and move the pointer. We interleave - * the two arrays, to (hopefully) get some locality for each backend. + * Also build PGPROC entries for auxiliary procs / prepared xacts (we + * however don't assign those to any NUMA node). */ - proc->fpLockBits = (uint64 *) fpPtr; - fpPtr += fpLockBitsSize; + node_procs = (NUM_AUXILIARY_PROCS + max_prepared_xacts); + + /* make sure to align the PGPROC array to memory page */ + fpPtr = (char *) TYPEALIGN(numa_page_size, fpPtr); + + /* remember this pointer too */ + partitions[numa_nodes].fastpath_ptr = fpPtr; + Assert(node_procs == partitions[numa_nodes].num_procs); + + fpPtr = fastpath_partition_init(fpPtr, node_procs, total_procs, -1, + fpLockBitsSize, fpRelIdSize); - proc->fpRelId = (Oid *) fpPtr; - fpPtr += fpRelIdSize; + total_procs += node_procs; + /* don't overflow the allocation */ Assert(fpPtr <= fpEndPtr); + Assert(total_procs = TotalProcs); + } + else + { + /* remember this pointer too */ + partitions[0].fastpath_ptr = fpPtr; + Assert(TotalProcs == partitions[0].num_procs); + + /* just treat everything as a single array, with no alignment */ + fpPtr = fastpath_partition_init(fpPtr, TotalProcs, 0, -1, + fpLockBitsSize, fpRelIdSize); + + /* don't overflow the allocation */ + Assert(fpPtr <= fpEndPtr); + } + + for (i = 0; i < TotalProcs; i++) + { + PGPROC *proc = procs[i]; + + Assert(proc->procnumber == i); + /* * Set up per-PGPROC semaphore, latch, and fpInfoLock. Prepared xact * dummy PGPROCs don't need these though - they're never associated