Skip to content

Commit a46311e

Browse files
committed
Try to avoid semaphore-related test failures on NetBSD/OpenBSD.
These two platforms have a remarkably tight default limit on the number of SysV semaphores in the system: SEMMNS is only 60 out-of-the-box. Unless manual action is taken to raise that, we'll only be able to allocate 3 sets of 16 usable semaphores each, leading to initdb setting max_connections to just 20. That's problematic because the core regression tests expect to be able to launch 20 concurrent sessions, leaving us with no headroom. This seems to be the cause of intermittent buildfarm failures on some machines. While there's no getting around the fact that you'd better raise SEMMNS for production use on these platforms, it does seem desirable for "make check" to pass reliably without that. We can make that happen, at least for awhile longer, with two small changes: * Change sysv_sema.c's SEMAS_PER_SET to 19, so that we can eat up all of the available semas not just most of them. * Change initdb to make the smallest max_connections value it will consider be 25 not 20. This is a back-patch of recent HEAD commit 38da053 into v17. The motivation for doing this now is that an upcoming bug-fix patch will give the new-in-17 slotsync worker process its own reserved PGPROC and hence also semaphore. With that patch but without this change, v17 would fail to start at all under the default SEMMNS on these platforms. Discussion: https://postgr.es/m/db2773a2-aca0-43d0-99c1-060efcd9954e@gmail.com Discussion: https://postgr.es/m/1808397.1735156190@sss.pgh.pa.us
1 parent fa61313 commit a46311e

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -781,19 +781,19 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
781781
<row>
782782
<entry><varname>SEMMNI</varname></entry>
783783
<entry>Maximum number of semaphore identifiers (i.e., sets)</entry>
784-
<entry>at least <literal>ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 16)</literal> plus room for other applications</entry>
784+
<entry>at least <literal>ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 19)</literal> plus room for other applications</entry>
785785
</row>
786786

787787
<row>
788788
<entry><varname>SEMMNS</varname></entry>
789789
<entry>Maximum number of semaphores system-wide</entry>
790-
<entry><literal>ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 16) * 17</literal> plus room for other applications</entry>
790+
<entry><literal>ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 19) * 20</literal> plus room for other applications</entry>
791791
</row>
792792

793793
<row>
794794
<entry><varname>SEMMSL</varname></entry>
795795
<entry>Maximum number of semaphores per set</entry>
796-
<entry>at least 17</entry>
796+
<entry>at least 20</entry>
797797
</row>
798798

799799
<row>
@@ -840,20 +840,20 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
840840
(<xref linkend="guc-max-connections"/>), allowed autovacuum worker process
841841
(<xref linkend="guc-autovacuum-max-workers"/>), allowed WAL sender process
842842
(<xref linkend="guc-max-wal-senders"/>), and allowed background
843-
process (<xref linkend="guc-max-worker-processes"/>), in sets of 16.
843+
process (<xref linkend="guc-max-worker-processes"/>), in sets of 19.
844844
Each such set will
845-
also contain a 17th semaphore which contains a <quote>magic
845+
also contain a 20th semaphore which contains a <quote>magic
846846
number</quote>, to detect collision with semaphore sets used by
847847
other applications. The maximum number of semaphores in the system
848848
is set by <varname>SEMMNS</varname>, which consequently must be at least
849849
as high as <varname>max_connections</varname> plus
850850
<varname>autovacuum_max_workers</varname> plus <varname>max_wal_senders</varname>,
851-
plus <varname>max_worker_processes</varname>, plus one extra for each 16
851+
plus <varname>max_worker_processes</varname>, plus one extra for each 19
852852
allowed connections plus workers (see the formula in <xref
853853
linkend="sysvipc-parameters"/>). The parameter <varname>SEMMNI</varname>
854854
determines the limit on the number of semaphore sets that can
855855
exist on the system at one time. Hence this parameter must be at
856-
least <literal>ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 16)</literal>.
856+
least <literal>ceil((max_connections + autovacuum_max_workers + max_wal_senders + max_worker_processes + 7) / 19)</literal>.
857857
Lowering the number
858858
of allowed connections is a temporary workaround for failures,
859859
which are usually confusingly worded <quote>No space

src/backend/port/sysv_sema.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */
5050
* we allocate. It must be *less than* your kernel's SEMMSL (max semaphores
5151
* per set) parameter, which is often around 25. (Less than, because we
5252
* allocate one extra sema in each set for identification purposes.)
53+
*
54+
* The present value of 19 is chosen with one eye on NetBSD/OpenBSD's default
55+
* SEMMNS setting of 60. Remembering the extra sema per set, this lets us
56+
* allocate three sets with 57 useful semaphores before exceeding that, which
57+
* is enough to run our core regression tests. Users of those systems will
58+
* still want to raise SEMMNS for any sort of production work, though.
5359
*/
54-
#define SEMAS_PER_SET 16
60+
#define SEMAS_PER_SET 19
5561

5662
#define IPCProtection (0600) /* access/modify by user only */
5763

src/bin/initdb/initdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ test_config_settings(void)
11191119
#define MIN_BUFS_FOR_CONNS(nconns) ((nconns) * 10)
11201120

11211121
static const int trial_conns[] = {
1122-
100, 50, 40, 30, 20
1122+
100, 50, 40, 30, 25
11231123
};
11241124
static const int trial_bufs[] = {
11251125
16384, 8192, 4096, 3584, 3072, 2560, 2048, 1536,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy