Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38da053

Browse files
committed
Try to avoid semaphore-related test failures on NetBSD/OpenBSD.
These two platforms have a remarkably tight default limit on thenumber of SysV semaphores in the system: SEMMNS is only 60out-of-the-box. Unless manual action is taken to raise that,we'll only be able to allocate 3 sets of 16 usable semaphoreseach, leading to initdb setting max_connections to just 20.That's problematic because the core regression tests expectto be able to launch 20 concurrent sessions, leaving us withno headroom. This seems to be the cause of intermittentbuildfarm failures on some machines.While there's no getting around the fact that you'd better raiseSEMMNS for production use on these platforms, it does seem desirablefor "make check" to pass reliably without that. We can make thathappen, at least for awhile longer, with two small changes:* Change sysv_sema.c's SEMAS_PER_SET to 19, so that we can eat upall of the available semas not just most of them.* Change initdb to make the smallest max_connections value it willconsider be 25 not 20.As of HEAD this will leave us with four free semaphores (using thedefault values for other relevant parameters such as max_wal_senders).So we won't need to consider this again until we've invented fivemore background processes. Maybe by then we can switch both theseplatforms to some other semaphore API.For the moment, do this only in master; there've not been fieldcomplaints that might justify a back-patch.Discussion:https://postgr.es/m/db2773a2-aca0-43d0-99c1-060efcd9954e@gmail.com
1 parentda9517f commit38da053

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

‎doc/src/sgml/runtime.sgml

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

788788
<row>
789789
<entry><varname>SEMMNS</varname></entry>
790790
<entry>Maximum number of semaphores system-wide</entry>
791-
<entry><literal>ceil(num_os_semaphores /16) *17</literal> plus room for other applications</entry>
791+
<entry><literal>ceil(num_os_semaphores /19) *20</literal> plus room for other applications</entry>
792792
</row>
793793

794794
<row>
795795
<entry><varname>SEMMSL</varname></entry>
796796
<entry>Maximum number of semaphores per set</entry>
797-
<entry>at least17</entry>
797+
<entry>at least20</entry>
798798
</row>
799799

800800
<row>
@@ -841,7 +841,7 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
841841
(<xref linkend="guc-max-connections"/>), allowed autovacuum worker process
842842
(<xref linkend="guc-autovacuum-max-workers"/>), allowed WAL sender process
843843
(<xref linkend="guc-max-wal-senders"/>), allowed background
844-
process (<xref linkend="guc-max-worker-processes"/>), etc., in sets of16.
844+
process (<xref linkend="guc-max-worker-processes"/>), etc., in sets of19.
845845
The runtime-computed parameter <xref linkend="guc-num-os-semaphores"/>
846846
reports the number of semaphores required. This parameter can be viewed
847847
before starting the server with a <command>postgres</command> command like:
@@ -851,17 +851,17 @@ $ <userinput>postgres -D $PGDATA -C num_os_semaphores</userinput>
851851
</para>
852852

853853
<para>
854-
Each set of16 semaphores will
855-
also contain a17th semaphore which contains a <quote>magic
854+
Each set of19 semaphores will
855+
also contain a20th semaphore which contains a <quote>magic
856856
number</quote>, to detect collision with semaphore sets used by
857857
other applications. The maximum number of semaphores in the system
858858
is set by <varname>SEMMNS</varname>, which consequently must be at least
859859
as high as <literal>num_os_semaphores</literal> plus one extra for
860-
each set of16 required semaphores (see the formula in <xref
860+
each set of19 required semaphores (see the formula in <xref
861861
linkend="sysvipc-parameters"/>). The parameter <varname>SEMMNI</varname>
862862
determines the limit on the number of semaphore sets that can
863863
exist on the system at one time. Hence this parameter must be at
864-
least <literal>ceil(num_os_semaphores /16)</literal>.
864+
least <literal>ceil(num_os_semaphores /19)</literal>.
865865
Lowering the number
866866
of allowed connections is a temporary workaround for failures,
867867
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-
#defineSEMAS_PER_SET16
60+
#defineSEMAS_PER_SET19
5561

5662
#defineIPCProtection(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
#defineMIN_BUFS_FOR_CONNS(nconns)((nconns) * 10)
11201120

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp