diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 305147246da..893b30eb31a 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -781,19 +781,19 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
SEMMNI
Maximum number of semaphore identifiers (i.e., sets)
- at least ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 16) plus room for other applications
+ at least ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 19) plus room for other applications
SEMMNS
Maximum number of semaphores system-wide
- ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 16) * 17 plus room for other applications
+ ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 19) * 20 plus room for other applications
SEMMSL
Maximum number of semaphores per set
- at least 17
+ at least 20
@@ -840,20 +840,20 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
(), allowed autovacuum worker process
(), allowed WAL sender process
(), and allowed background
- process (), in sets of 16.
+ process (), in sets of 19.
Each such set will
- also contain a 17th semaphore which contains a magic
+ also contain a 20th semaphore which contains a magic
number
, to detect collision with semaphore sets used by
other applications. The maximum number of semaphores in the system
is set by SEMMNS, which consequently must be at least
as high as max_connections plus
autovacuum_max_workers plus max_wal_senders,
- plus max_worker_processes, plus one extra for each 16
+ plus max_worker_processes, plus one extra for each 19
allowed connections plus workers (see the formula in ). The parameter SEMMNI
determines the limit on the number of semaphore sets that can
exist on the system at one time. Hence this parameter must be at
- least ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 16).
+ least ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 19).
Lowering the number
of allowed connections is a temporary workaround for failures,
which are usually confusingly worded No space
diff --git a/src/backend/port/sysv_sema.c b/src/backend/port/sysv_sema.c
index 1454f96b5f3..aafd44c866e 100644
--- a/src/backend/port/sysv_sema.c
+++ b/src/backend/port/sysv_sema.c
@@ -50,8 +50,14 @@ typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */
* we allocate. It must be *less than* your kernel's SEMMSL (max semaphores
* per set) parameter, which is often around 25. (Less than, because we
* allocate one extra sema in each set for identification purposes.)
+ *
+ * The present value of 19 is chosen with one eye on NetBSD/OpenBSD's default
+ * SEMMNS setting of 60. Remembering the extra sema per set, this lets us
+ * allocate three sets with 57 useful semaphores before exceeding that, which
+ * is enough to run our core regression tests. Users of those systems will
+ * still want to raise SEMMNS for any sort of production work, though.
*/
-#define SEMAS_PER_SET 16
+#define SEMAS_PER_SET 19
#define IPCProtection (0600) /* access/modify by user only */
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index b050355ca91..f2c61bc5637 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1119,7 +1119,7 @@ test_config_settings(void)
#define MIN_BUFS_FOR_CONNS(nconns) ((nconns) * 10)
static const int trial_conns[] = {
- 100, 50, 40, 30, 20
+ 100, 50, 40, 30, 25
};
static const int trial_bufs[] = {
16384, 8192, 4096, 3584, 3072, 2560, 2048, 1536,