Skip to content

Commit 3d21f08

Browse files
committed
Update user docs for switch to POSIX semaphores.
Since commit ecb0d20 hasn't crashed and burned, here's the promised docs update for it. In addition to explaining that Linux and FreeBSD ports now use POSIX semaphores, I did some wordsmithing on pre-existing wording; in particular trying to clarify which SysV parameters need to be set with an eye to total usage across all applications.
1 parent 0137caf commit 3d21f08

File tree

1 file changed

+50
-33
lines changed

1 file changed

+50
-33
lines changed

doc/src/sgml/runtime.sgml

+50-33
Original file line numberDiff line numberDiff line change
@@ -605,27 +605,47 @@ psql: could not connect to server: No such file or directory
605605
</indexterm>
606606

607607
<para>
608-
Shared memory and semaphores are collectively referred to as
609-
<quote><systemitem class="osname">System V</>
610-
<acronym>IPC</></quote> (together with message queues, which are not
611-
relevant for <productname>PostgreSQL</>). Except on
612-
<systemitem class="osname">Windows</>, where <productname>PostgreSQL</>
613-
provides its own replacement implementation of these facilities, these
614-
facilities are required in order to run
615-
<productname>PostgreSQL</>.
608+
<productname>PostgreSQL</> requires the operating system to provide
609+
inter-process communication (<acronym>IPC</>) features, specifically
610+
shared memory and semaphores. Unix-derived systems typically provide
611+
<quote><systemitem class="osname">System V</></> <acronym>IPC</>,
612+
<quote><systemitem class="osname">POSIX</></> <acronym>IPC</>, or both.
613+
<systemitem class="osname">Windows</> has its own implementation of
614+
these features and is not discussed here.
616615
</para>
617616

618617
<para>
619618
The complete lack of these facilities is usually manifested by an
620-
<errorname>Illegal system call</> error upon server start. In
621-
that case there is no alternative but to reconfigure your
619+
<quote><errorname>Illegal system call</></quote> error upon server
620+
start. In that case there is no alternative but to reconfigure your
622621
kernel. <productname>PostgreSQL</> won't work without them.
623622
This situation is rare, however, among modern operating systems.
624623
</para>
625624

626625
<para>
627-
When <productname>PostgreSQL</> exceeds one of the various hard
628-
<acronym>IPC</> limits, the server will refuse to start and
626+
Upon starting the server, <productname>PostgreSQL</> normally allocates
627+
a very small amount of System V shared memory, as well as a much larger
628+
amount of POSIX (<function>mmap</>) shared memory.
629+
In addition a significant number of semaphores, which can be either
630+
System V or POSIX style, are created at server startup. Currently,
631+
POSIX semaphores are used on Linux and FreeBSD systems while other
632+
platforms use System V semaphores.
633+
</para>
634+
635+
<note>
636+
<para>
637+
Prior to <productname>PostgreSQL</> 9.3, only System V shared memory
638+
was used, so the amount of System V shared memory required to start the
639+
server was much larger. If you are running an older version of the
640+
server, please consult the documentation for your server version.
641+
</para>
642+
</note>
643+
644+
<para>
645+
System V <acronym>IPC</> features are typically constrained by
646+
system-wide allocation limits.
647+
When <productname>PostgreSQL</> exceeds one of these limits,
648+
the server will refuse to start and
629649
should leave an instructive error message describing the problem
630650
and what to do about it. (See also <xref
631651
linkend="server-start-failures">.) The relevant kernel
@@ -634,15 +654,6 @@ psql: could not connect to server: No such file or directory
634654
them, however, vary. Suggestions for some platforms are given below.
635655
</para>
636656

637-
<note>
638-
<para>
639-
Prior to <productname>PostgreSQL</> 9.3, the amount of System V shared
640-
memory required to start the server was much larger. If you are running
641-
an older version of the server, please consult the documentation for
642-
your server version.
643-
</para>
644-
</note>
645-
646657
<table id="sysvipc-parameters">
647658
<title><systemitem class="osname">System V</> <acronym>IPC</> Parameters</title>
648659

@@ -651,15 +662,15 @@ psql: could not connect to server: No such file or directory
651662
<row>
652663
<entry>Name</>
653664
<entry>Description</>
654-
<entry>Reasonable values</>
665+
<entry>Values needed to run one <productname>PostgreSQL</> instance</>
655666
</row>
656667
</thead>
657668

658669
<tbody>
659670
<row>
660671
<entry><varname>SHMMAX</></>
661672
<entry>Maximum size of shared memory segment (bytes)</>
662-
<entry>at least 1kB (more if running many copies of the server)</entry>
673+
<entry>at least 1kB, but the default is usually much higher</entry>
663674
</row>
664675

665676
<row>
@@ -671,7 +682,9 @@ psql: could not connect to server: No such file or directory
671682
<row>
672683
<entry><varname>SHMALL</></>
673684
<entry>Total amount of shared memory available (bytes or pages)</>
674-
<entry>if bytes, same as <varname>SHMMAX</varname>; if pages, <literal>ceil(SHMMAX/PAGE_SIZE)</literal></>
685+
<entry>same as <varname>SHMMAX</varname> if bytes,
686+
or <literal>ceil(SHMMAX/PAGE_SIZE)</literal> if pages,
687+
plus room for other applications</>
675688
</row>
676689

677690
<row>
@@ -689,7 +702,7 @@ psql: could not connect to server: No such file or directory
689702
<row>
690703
<entry><varname>SEMMNI</></>
691704
<entry>Maximum number of semaphore identifiers (i.e., sets)</>
692-
<entry>at least <literal>ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16)</literal></>
705+
<entry>at least <literal>ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16)</literal> plus room for other applications</>
693706
</row>
694707

695708
<row>
@@ -725,9 +738,8 @@ psql: could not connect to server: No such file or directory
725738
(typically 48 bytes, on 64-bit platforms) for each copy of the server.
726739
On most modern operating systems, this amount can easily be allocated.
727740
However, if you are running many copies of the server, or if other
728-
applications are also using System V shared memory, it may be necessary
729-
to increase <varname>SHMMAX</>, the maximum size in bytes of a shared
730-
memory segment, or <varname>SHMALL</>, the total amount of System V shared
741+
applications are also using System V shared memory, it may be necessary to
742+
increase <varname>SHMALL</>, which is the total amount of System V shared
731743
memory system-wide. Note that <varname>SHMALL</> is measured in pages
732744
rather than bytes on many systems.
733745
</para>
@@ -742,6 +754,7 @@ psql: could not connect to server: No such file or directory
742754
</para>
743755

744756
<para>
757+
When using System V semaphores,
745758
<productname>PostgreSQL</> uses one semaphore per allowed connection
746759
(<xref linkend="guc-max-connections">), allowed autovacuum worker process
747760
(<xref linkend="guc-autovacuum-max-workers">) and allowed background
@@ -779,15 +792,19 @@ psql: could not connect to server: No such file or directory
779792
</para>
780793

781794
<para>
782-
The <varname>SEMMSL</> parameter, which determines how many
783-
semaphores can be in a set, must be at least 17 for
795+
Various other settings related to <quote>semaphore undo</>, such as
796+
<varname>SEMMNU</> and <varname>SEMUME</>, do not affect
784797
<productname>PostgreSQL</>.
785798
</para>
786799

787800
<para>
788-
Various other settings related to <quote>semaphore undo</>, such as
789-
<varname>SEMMNU</> and <varname>SEMUME</>, do not affect
790-
<productname>PostgreSQL</>.
801+
When using POSIX semaphores, the number of semaphores needed is the
802+
same as for System V, that is one semaphore per allowed connection
803+
(<xref linkend="guc-max-connections">), allowed autovacuum worker process
804+
(<xref linkend="guc-autovacuum-max-workers">) and allowed background
805+
process (<xref linkend="guc-max-worker-processes">).
806+
On the platforms where this option is preferred, there is no specific
807+
kernel limit on the number of POSIX semaphores.
791808
</para>
792809

793810

0 commit comments

Comments
 (0)