Shed some light onto SysV IPC configuration.
authorPeter Eisentraut
Sat, 22 Jul 2000 14:49:01 +0000 (14:49 +0000)
committerPeter Eisentraut
Sat, 22 Jul 2000 14:49:01 +0000 (14:49 +0000)
doc/src/sgml/runtime.sgml
src/backend/storage/ipc/ipc.c

index 78978fdb35c70ae770e53bf2b39fc21bc0ef6be6..5b85a80c6b928423ab003b674914670adeedb101 100644 (file)
@@ -1,5 +1,5 @@
 
 
 
@@ -267,13 +267,13 @@ FATAL: StreamServerPort: bind() failed: Permission denied
     
      A message like
 
-IpcMemoryCreate: shmget(5440001, 83918612, 01600) failed: Invalid argument
+IpcMemoryCreate: shmget(key=5440001, size=83918612, 01600) failed: Invalid argument
 FATAL 1:  ShmemCreate: cannot create region
 
      probably means that your kernel's limit on the size of shared
      memory areas is smaller than the buffer area that Postgres is
      trying to create (83918612 bytes in this example). Or it could
-     mean that you don't have SysV-style shared memory support
+     mean that you don't have System-V-style shared memory support
      configured into your kernel at all. As a temporary workaround,
      you can try starting the postmaster with a smaller-than-normal
      number of buffers ( switch). You will
@@ -286,17 +286,22 @@ FATAL 1:  ShmemCreate: cannot create region
     
      An error like
 
-IpcSemaphoreCreate: semget(5440026, 16, 0600) failed: No space left on device
+IpcSemaphoreCreate: semget(key=5440026, num=16, 01600) failed: No space left on device
 
      does not mean that you've run out of disk
-     space; it means that your kernel's limit on the number of SysV
-     semaphores is smaller than the number
+     space; it means that your kernel's limit on the number of System
+     semaphores is smaller than the number
      Postgres wants to create. As above,
      you may be able to work around the problem by starting the
      postmaster with a reduced number of backend processes
      ( switch), but you'll eventually want to
      increase the kernel limit.
     
+
+    
+     Details about configuring System V IPC facilities are given in
+     .
+    
    
 
    
@@ -1073,6 +1078,445 @@ env PGOPTIONS='--geqo=off' psql
  
 
 
+  Managing Kernel Resources
+
+  
+   A large Postgres installation can quickly hit
+   various operating system resource limits. (On some systems, the
+   factory defaults are so low that you don't even need a really
+   large installation.) If you have encountered this kind of
+   problem then keep reading.
+  
+
+  
+   Shared Memory and Semaphores
+
+   
+    Shared memory and semaphores are collectively referred to as
+    System V IPC (together with message queues, which are
+    not relevant for Postgres). Almost all modern
+    operating systems provide these features, but not all of them have
+    them turned on or sufficiently sized by default, especially
+    systems with BSD heritage. (For the QNX port,
+    Postgres provides its own replacement
+    implementation of these facilities.)
+   
+
+   
+    The complete lack of these facilities is usually manifested by an
+    Illegal system call error upon postmaster start. In
+    that case there's nothing left to do but to reconfigure your
+    kernel -- Postgres won't work without them.
+   
+
+   
+    When Postgres exceeds one of the various hard
+    limits of the IPC resources then the postmaster will refuse to
+    start up and should leave a marginally instructive error message
+    about which problem was encountered and what needs to be done
+    about it. The relevant kernel parameters have a relatively
+    consistent nomenclature across systems; 
+    linkend="sysvipc-parameters"> gives an overview. The methods to
+    set them, however, vary; suggestions for some platforms are given
+    below. Be aware, however, that you will have to reboot your
+    machine at best, or possibly recompile the kernel, to change these
+    settings.
+   
+
+
+   
+    System V IPC parameters</></div> <div class="diff add">+</div> <div class="diff add">+    <tgroup cols="3"></div> <div class="diff add">+     <thead></div> <div class="diff add">+      <row></div> <div class="diff add">+       <entry>Name</></div> <div class="diff add">+       <entry>Description</></div> <div class="diff add">+       <entry>Reasonable values</></div> <div class="diff add">+      </row></div> <div class="diff add">+     </thead></div> <div class="diff add">+</div> <div class="diff add">+     <tbody></div> <div class="diff add">+      <row></div> <div class="diff add">+       <entry><varname>SHMMAX</></></div> <div class="diff add">+       <entry>Maximum size of shared memory segment (bytes)</></div> <div class="diff add">+       <entry>512 kB + 8192 * buffers + extra ... infinity</entry></div> <div class="diff add">+      </row></div> <div class="diff add">+</div> <div class="diff add">+      <row></div> <div class="diff add">+       <entry><varname>SHMMIN</></></div> <div class="diff add">+       <entry>Minimum size of shared memory segment (bytes)</></div> <div class="diff add">+       <entry>1 (at most 144)</></div> <div class="diff add">+      </row></div> <div class="diff add">+</div> <div class="diff add">+      <row></div> <div class="diff add">+       <entry><varname>SHMSEG</></></div> <div class="diff add">+       <entry>Maximum number of shared memory segments per process</></div> <div class="diff add">+       <entry>Must be at least 3, but the default is much higher.</></div> <div class="diff add">+      </row></div> <div class="diff add">+</div> <div class="diff add">+       <row></div> <div class="diff add">+        <entry><varname>SHMMNI</></></div> <div class="diff add">+        <entry>Maximum number of shared memory segments system-wide</></div> <div class="diff add">+        <entry>like <varname>SHMSEG</> + room for other applications</></div> <div class="diff add">+       </row></div> <div class="diff add">+</div> <div class="diff add">+       <row></div> <div class="diff add">+        <entry><varname>SEMMNI</></></div> <div class="diff add">+        <entry>Maximum number of semaphore identifiers (i.e., sets)</></div> <div class="diff add">+        <entry>>= ceil(max_connections % 16)</></div> <div class="diff add">+       </row></div> <div class="diff add">+</div> <div class="diff add">+       <row></div> <div class="diff add">+        <entry><varname>SEMMNS</></></div> <div class="diff add">+        <entry>Maximum number of semaphores system-wide</></div> <div class="diff add">+        <entry>number of allowed connections, rounded up to multiple of 16</></div> <div class="diff add">+       </row></div> <div class="diff add">+</div> <div class="diff add">+       <row></div> <div class="diff add">+        <entry><varname>SEMMSL</></></div> <div class="diff add">+        <entry>Maximum number of semaphores per set</></div> <div class="diff add">+        <entry>>= 16</></div> <div class="diff add">+       </row></div> <div class="diff add">+</div> <div class="diff add">+       <row></div> <div class="diff add">+        <entry><varname>SEMMAP</></></div> <div class="diff add">+        <entry>Number of entries in semaphore map</></div> <div class="diff add">+        <entry>see text</></div> <div class="diff add">+       </row></div> <div class="diff add">+</div> <div class="diff add">+       <row></div> <div class="diff add">+        <entry><varname>SEMVMX</></></div> <div class="diff add">+        <entry>Maximum value of semaphore</></div> <div class="diff add">+        <entry>>= 255  (The default is often 32767, don't change unless asked to.)</></div> <div class="diff add">+       </row></div> <div class="diff add">+</div> <div class="diff add">+     </tbody></div> <div class="diff add">+    </tgroup></div> <div class="diff add">+   </table></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+   <para></div> <div class="diff add">+    The most important shared memory parameter is <varname>SHMMAX</>,</div> <div class="diff add">+    the maximum size, in bytes, that a shared memory segment can have.</div> <div class="diff add">+    If you get an error message from <function>shmget</> along the</div> <div class="diff add">+    lines of <errorname>Invalid argument</> then it is possible that</div> <div class="diff add">+    this limit has been exceeded. The size of the required shared</div> <div class="diff add">+    memory segments varies both with the number of requested buffers</div> <div class="diff add">+    (<option>-B</> option) and the number of allowed connections</div> <div class="diff add">+    (<option>-N</> option), although the former is the dominant item.</div> <div class="diff add">+    (You can therefore, as a temporary solution, lower these settings</div> <div class="diff add">+    to get rid of the failures.) As a rough approximation you can</div> <div class="diff add">+    estimate the required segment size as the number of buffers times</div> <div class="diff add">+    the block size (8192 kB by default) plus ample overhead (at least</div> <div class="diff add">+    half a megabyte). Any error message you might get will contain the</div> <div class="diff add">+    size of the failed allocation. (<productname>Postgres</> will</div> <div class="diff add">+    actually use three shared memory segments, but the size of the</div> <div class="diff add">+    other two is negligible for this consideration.)</div> <div class="diff add">+   </para></div> <div class="diff add">+</div> <div class="diff add">+   <para></div> <div class="diff add">+    Less likely to cause problems is the minimum size for shared</div> <div class="diff add">+    memory segments (<varname>SHMMIN</>), which must be at least 144</div> <div class="diff add">+    for <productname>Postgres</> (it's usually just 1), and the</div> <div class="diff add">+    maximum number of segments system-wide (<varname>SHMMNI</>, as</div> <div class="diff add">+    mentioned, 3 are needed) or per-process (<varname>SHMSEG</>,</div> <div class="diff add">+    ditto). Some systems also have a limit on the total amount of</div> <div class="diff add">+    shared memory in the system; see the platform-specific</div> <div class="diff add">+    instructions below.</div> <div class="diff add">+   </para></div> <div class="diff add">+</div> <div class="diff add">+   <para></div> <div class="diff add">+    <productname>Postgres</> uses one semaphore per allowed connection</div> <div class="diff add">+    (<option>-N</> option), in sets of 16. The maximum number of</div> <div class="diff add">+    semaphores in the system is set by <varname>SEMMNS</>, which</div> <div class="diff add">+    consequently must be at least as high as the connection setting.</div> <div class="diff add">+    The parameter <varname>SEMMNI</> determines the limit on the</div> <div class="diff add">+    number of semaphore sets that can exist on the system at one time.</div> <div class="diff add">+    Hence this parameter must be at least</div> <div class="diff add">+    <literal>ceil(max_connections % 16)</>. Lowering the number of</div> <div class="diff add">+    allowed connections is a temporary workaround for failures, which</div> <div class="diff add">+    are usually confusingly worded <quote><errorname>No space left on</div> <div class="diff add">+    device</></>, from the function <function>semget()</>.</div> <div class="diff add">+   </para></div> <div class="diff add">+</div> <div class="diff add">+   <para></div> <div class="diff add">+    In some cases it might also turn out to be necessary to increase</div> <div class="diff add">+    <varname>SEMMAP</> to be at least on the order of</div> <div class="diff add">+    <varname>SEMMNS</>. This parameter defines the size of the</div> <div class="diff add">+    semaphore resource map, in which each contiguous block of available</div> <div class="diff add">+    semaphores needs an entry. When a semaphore set is freed it is</div> <div class="diff add">+    either added to an existing entry that is adjacent to the freed</div> <div class="diff add">+    block or it is registered under a new map entry. If the map is</div> <div class="diff add">+    full, the freed semaphores gets lost (until reboot). Fragmentation</div> <div class="diff add">+    of the semaphore space could therefore over time lead to less</div> <div class="diff add">+    available semaphores than there should be.</div> <div class="diff add">+   </para></div> <div class="diff add">+</div> <div class="diff add">+   <para></div> <div class="diff add">+    The <varname>SEMMSL</> parameter, which determines how many</div> <div class="diff add">+    semaphores can be in a set, must be at least 16 for</div> <div class="diff add">+    <productname>Postgres</>.</div> <div class="diff add">+   </para></div> <div class="diff add">+</div> <div class="diff add">+   <para></div> <div class="diff add">+    Various settings related to <quote>semaphore undo</>, such as</div> <div class="diff add">+    <varname>SEMMNU</> and <varname>SEMUME</>, are not of relevance</div> <div class="diff add">+    with <productname>Postgres</>.</div> <div class="diff add">+   </para></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+   <para></div> <div class="diff add">+    <variablelist></div> <div class="diff add">+</div> <div class="diff add">+     <varlistentry></div> <div class="diff add">+      <term>BSD/OS</></div> <div class="diff add">+      <listitem></div> <div class="diff add">+       <formalpara></div> <div class="diff add">+        <title>Shared Memory</></div> <div class="diff add">+        <para></div> <div class="diff add">+         By default, only 4 MB of shared memory is supported. Keep in</div> <div class="diff add">+         mind that shared memory is not pageable; it is locked in RAM.</div> <div class="diff add">+         To increase the number of buffers supported by the</div> <div class="diff add">+         postmaster, increase <varname>SHMMAXPGS</> by 1024 for every</div> <div class="diff add">+         additional 4 MB of shared memory:</div> <div class="diff add">+<programlisting></div> <div class="diff add">+/sys/sys/shm.h:69:#define       SHMMAXPGS       1024    /* max hardware pages... */</div> <div class="diff add">+</programlisting></div> <div class="diff add">+         The default setting of 1024 is for a maximum of 4 MB of shared</div> <div class="diff add">+         memory.</div> <div class="diff add">+        </para></div> <div class="diff add">+       </formalpara></div> <div class="diff add">+</div> <div class="diff add">+       <para></div> <div class="diff add">+        For those running 4.1 or later, just recompile the kernel and</div> <div class="diff add">+        reboot. For those running earlier releases, use</div> <div class="diff add">+        <application>bpatch</> to find the <varname>sysptsize</> value</div> <div class="diff add">+        for the current kernel. This is computed dynamically at</div> <div class="diff add">+        bootup.</div> <div class="diff add">+<screen></div> <div class="diff add">+$ <userinput>bpatch -r sysptsize</></div> <div class="diff add">+<computeroutput>0x9 = 9</></div> <div class="diff add">+</screen></div> <div class="diff add">+        Next, change <varname>SYSPTSIZE</> to a hard-coded value. Use</div> <div class="diff add">+        the bpatch value, plus add 1 for every additional 4 MB of</div> <div class="diff add">+        shared memory you desire.</div> <div class="diff add">+<programlisting></div> <div class="diff add">+/sys/i386/i386/i386_param.c:28:#define  SYSPTSIZE 0        /* dynamically... */</div> <div class="diff add">+</programlisting></div> <div class="diff add">+        <varname>sysptsize</> can not be changed by sysctl on the fly.</div> <div class="diff add">+       </para></div> <div class="diff add">+</div> <div class="diff add">+       <formalpara></div> <div class="diff add">+        <title>Semaphores</></div> <div class="diff add">+        <para></div> <div class="diff add">+         You may need to increase the number of semaphores. By</div> <div class="diff add">+         default, <productname>Postgres</> allocates 32 semaphores,</div> <div class="diff add">+         one for each backend connection. This is just over half the</div> <div class="diff add">+         default system total of 60.</div> <div class="diff add">+        </para></div> <div class="diff add">+       </formalpara></div> <div class="diff add">+</div> <div class="diff add">+       <para></div> <div class="diff add">+        The defaults are in <filename>/sys/sys/sem.h</>:</div> <div class="diff add">+<programlisting></div> <div class="diff add">+/* Configuration parameters */</div> <div class="diff add">+#ifndef SEMMNI</div> <div class="diff add">+#define SEMMNI  10              /* # of semaphore identifiers */</div> <div class="diff add">+#endif</div> <div class="diff add">+#ifndef SEMMNS</div> <div class="diff add">+#define SEMMNS  60              /* # of semaphores in system */</div> <div class="diff add">+#endif</div> <div class="diff add">+#ifndef SEMUME</div> <div class="diff add">+#define SEMUME  10              /* max # of undo entries per process */</div> <div class="diff add">+#endif</div> <div class="diff add">+#ifndef SEMMNU</div> <div class="diff add">+#define SEMMNU  30              /* # of undo structures in system */</div> <div class="diff add">+#endif</div> <div class="diff add">+</programlisting></div> <div class="diff add">+        Set the values you want in your kernel config file, e.g.:</div> <div class="diff add">+<programlisting></div> <div class="diff add">+options "SEMMNI=40"</div> <div class="diff add">+options "SEMMNS=240"</div> <div class="diff add">+options "SEMUME=40"</div> <div class="diff add">+options "SEMMNU=120"</div> <div class="diff add">+</programlisting></div> <div class="diff add">+       </para></div> <div class="diff add">+      </listitem></div> <div class="diff add">+     </varlistentry></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+     <varlistentry></div> <div class="diff add">+      <term>FreeBSD</></div> <div class="diff add">+      <listitem></div> <div class="diff add">+       <para></div> <div class="diff add">+        The options <varname>SYSVSHM</> and <varname>SYSVSEM</> need</div> <div class="diff add">+        to be enabled when the kernel is compiled. (They are by</div> <div class="diff add">+        default.) The maximum size of shared memory is determined by</div> <div class="diff add">+        the option <varname>SHMMAXPGS</> (in pages). The following</div> <div class="diff add">+        shows an example on how to set the various parameters:</div> <div class="diff add">+<programlisting></div> <div class="diff add">+options         SYSVSHM                                                           </div> <div class="diff add">+options         SHMMAXPGS=4096                                                    </div> <div class="diff add">+options         SHMSEG=256                                                        </div> <div class="diff add">+                                                                                  </div> <div class="diff add">+options         SYSVSEM                                                           </div> <div class="diff add">+options         SEMMNI=256                                                        </div> <div class="diff add">+options         SEMMNS=512                                                        </div> <div class="diff add">+options         SEMMNU=256                                                        </div> <div class="diff add">+options         SEMMAP=256</div> <div class="diff add">+</programlisting></div> <div class="diff add">+       </para></div> <div class="diff add">+      </listitem></div> <div class="diff add">+     </varlistentry></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+     <varlistentry></div> <div class="diff add">+      <term>HPUX</></div> <div class="diff add">+      <listitem></div> <div class="diff add">+       <para></div> <div class="diff add">+        The default settings tend to suffice for normal installations.</div> <div class="diff add">+        On <productname>HPUX</> 10, the factory default for</div> <div class="diff add">+        <varname>SEMMNS</> is 128, which might be too low for larger</div> <div class="diff add">+        database sites.</div> <div class="diff add">+       </para></div> <div class="diff add">+       <para></div> <div class="diff add">+        IPC parameters can be set in the <application>System</div> <div class="diff add">+        Administration Manager</> (<acronym>SAM</>) under</div> <div class="diff add">+        <menuchoice><guimenu>Kernel</div> <div class="diff add">+        Configuration</><guimenuitem>Configurable Parameters</></>.</div> <div class="diff add">+        Hit <guibutton>Create A New Kernel</> when you're done.</div> <div class="diff add">+       </para></div> <div class="diff add">+      </listitem></div> <div class="diff add">+     </varlistentry></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+     <varlistentry></div> <div class="diff add">+      <term>Linux</></div> <div class="diff add">+      <listitem></div> <div class="diff add">+       <para></div> <div class="diff add">+        System V IPC is enabled by default and sufficiently sized for</div> <div class="diff add">+        most uses. The relevant parameters are in</div> <div class="diff add">+        <filename>/usr/src/linux/include/asm-<replaceable>xxx</>/shmparam.h</></div> <div class="diff add">+        and <filename>/usr/src/linux/include/linux/sem.h</>. Be sure</div> <div class="diff add">+        to do <command>make dep</> before rebuilding the kernel.</div> <div class="diff add">+       </para></div> <div class="diff add">+      </listitem></div> <div class="diff add">+     </varlistentry></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+     <varlistentry></div> <div class="diff add">+      <term>SCO OpenServer</></div> <div class="diff add">+      <listitem></div> <div class="diff add">+       <para></div> <div class="diff add">+        In the default configuration, only 512 kB of shared memory per</div> <div class="diff add">+        segment is allowed, which is about enough for <option>-B 24 -N</div> <div class="diff add">+        12</>. To increase the setting, first change the directory to</div> <div class="diff add">+        <filename>/etc/conf/cf.d</>. To display the current value of</div> <div class="diff add">+        <varname>SHMMAX</>, in bytes, run</div> <div class="diff add">+<programlisting></div> <div class="diff add">+./configure -y SHMMAX</div> <div class="diff add">+</programlisting></div> <div class="diff add">+        To set a new value for <varname>SHMMAX</>, run:</div> <div class="diff add">+<programlisting></div> <div class="diff add">+./configure SHMMAX=<replaceable>value</></div> <div class="diff add">+</programlisting></div> <div class="diff add">+        where <replaceable>value</> is the new value you want to use</div> <div class="diff add">+        (in bytes). After setting <varname>SHMMAX</>, rebuild the kernel</div> <div class="diff add">+<programlisting></div> <div class="diff add">+./link_unix</div> <div class="diff add">+</programlisting></div> <div class="diff add">+        and reboot.</div> <div class="diff add">+       </para></div> <div class="diff add">+      </listitem></div> <div class="diff add">+     </varlistentry></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+     <varlistentry></div> <div class="diff add">+      <term>Solaris</></div> <div class="diff add">+      <listitem></div> <div class="diff add">+       <para></div> <div class="diff add">+        At least in version 2.6, the maximum size of a shared memory</div> <div class="diff add">+        segment is set too low for <productname>Postgres</>. The</div> <div class="diff add">+        relevant settings can be changed in <filename>/etc/system</>,</div> <div class="diff add">+        for example:</div> <div class="diff add">+<programlisting></div> <div class="diff add">+set shmsys:shminfo_shmmax=0x2000000</div> <div class="diff add">+set shmsys:shminfo_shmmin=1</div> <div class="diff add">+set shmsys:shminfo_shmmni=256</div> <div class="diff add">+set shmsys:shminfo_shmseg=256</div> <div class="diff add">+</div> <div class="diff add">+set semsys:seminfo_semmap=256</div> <div class="diff add">+set semsys:seminfo_semmni=512</div> <div class="diff add">+set semsys:seminfo_semmns=512</div> <div class="diff add">+set semsys:seminfo_semmsl=32</div> <div class="diff add">+</programlisting></div> <div class="diff add">+        You need to reboot to make the changes effective.</div> <div class="diff add">+       </para></div> <div class="diff add">+</div> <div class="diff add">+       <para></div> <div class="diff add">+        See also <ulink</div> <div class="diff add">+        url="http://www.sunworld.com/swol-09-1997/swol-09-insidesolaris.html">http://www.sunworld.com/swol-09-1997/swol-09-insidesolaris.html</></div> <div class="diff add">+        for information on shared memory under</div> <div class="diff add">+        <productname>Solaris</>.</div> <div class="diff add">+       </para></div> <div class="diff add">+      </listitem></div> <div class="diff add">+     </varlistentry></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff add">+     <varlistentry></div> <div class="diff add">+      <term>UnixWare</></div> <div class="diff add">+      <listitem></div> <div class="diff add">+       <para></div> <div class="diff add">+        On <productname>UnixWare</> 7, the maximum size for shared</div> <div class="diff add">+        memory segments is 512 kB in the default configuration. This</div> <div class="diff add">+        is enough for about <option>-B 24 -N 12</>. To display the</div> <div class="diff add">+        current value of <varname>SHMMAX</>, run</div> <div class="diff add">+<programlisting></div> <div class="diff add">+/etc/conf/bin/idtune -g SHMMAX</div> <div class="diff add">+</programlisting></div> <div class="diff add">+        which displays the current, default, minimum, and maximum</div> <div class="diff add">+        values, in bytes. To set a new value for <varname>SHMMAX</>,</div> <div class="diff add">+        run:</div> <div class="diff add">+<programlisting></div> <div class="diff add">+/etc/conf/bin/idtune SHMMAX <replaceable>value</></div> <div class="diff add">+</programlisting></div> <div class="diff add">+        where <replaceable>value</> is the new value you want to use</div> <div class="diff add">+        (in bytes). After setting <varname>SHMMAX</>, rebuild the</div> <div class="diff add">+        kernel</div> <div class="diff add">+<programlisting></div> <div class="diff add">+/etc/conf/bin/idbuild -B</div> <div class="diff add">+</programlisting></div> <div class="diff add">+        and reboot.</div> <div class="diff add">+       </para></div> <div class="diff add">+      </listitem></div> <div class="diff add">+     </varlistentry></div> <div class="diff add">+</div> <div class="diff add">+    </variablelist></div> <div class="diff add">+</div> <div class="diff add">+    <note></div> <div class="diff add">+     <para></div> <div class="diff add">+      If your platform is not listed here, please consider</div> <div class="diff add">+      contributing some information.</div> <div class="diff add">+     </para></div> <div class="diff add">+    </note></div> <div class="diff add">+   </para></div> <div class="diff add">+  </sect2></div> <div class="diff add">+</div> <div class="diff add">+<!--</div> <div class="diff add">+ Other fun things to write about one day:</div> <div class="diff add">+ * number of processes per user and system-wide (soft/hard limit)</div> <div class="diff add">+ * open files/inodes per user and system-wide (soft/hard limit)</div> <div class="diff add">+   (Think about this both ways: Increasing it to allow Postgres to</div> <div class="diff add">+   open more files, and decreasing it to prevent Postgres from taking</div> <div class="diff add">+   up all file descriptors.)</div> <div class="diff add">+ * stack and data segment size, plain-old memory limit</div> <div class="diff add">+--> </div> <div class="diff add">+</div> <div class="diff add">+ </sect1></div> <div class="diff add">+</div> <div class="diff add">+</div> <div class="diff ctx">  <sect1 id="locale"></div> <div class="diff ctx">   <title>Locale Support
   
@@ -1142,8 +1586,9 @@ postmaster -B 1024 -S -D/usr/local/pgsql/data/ -o '-Fe'
       and if locale is broken perl -v will complain
       something like:
 
-8:17[mira]:~/WWW/postgres>setenv LC_CTYPE not_exist
-8:18[mira]:~/WWW/postgres>perl -v
+export LC_CTYPE='not_exist'
+perl -v
+
 perl: warning: Setting locale failed.
 perl: warning: Please check that your locale settings:
 LC_ALL = (unset),
@@ -1151,6 +1596,7 @@ LC_CTYPE = "not_exist",
 LANG = (unset)
 are supported and installed on your system.
 perl: warning: Falling back to the standard locale ("C").
+
 
      
     
index 8e4a29041e575c1123060efaac81bbd83fcbf47a..942e72cac03d2fd6088ea5e77c99255ba1dc6003 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.48 2000/05/31 00:28:29 petere Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.49 2000/07/22 14:49:01 petere Exp $
  *
  * NOTES
  *
@@ -54,7 +54,6 @@ bool      proc_exit_inprogress = false;
 static int UsePrivateMemory = 0;
 
 static void IpcMemoryDetach(int status, char *shmaddr);
-static void IpcConfigTip(void);
 
 /* ----------------------------------------------------------------
  *                     exit() handling stuff
@@ -241,7 +240,9 @@ IPCPrivateSemaphoreKill(int status,
    union semun semun;
    semun.val = 0;      /* unused */
 
-   semctl(semId, 0, IPC_RMID, semun);
+   if (semctl(semId, 0, IPC_RMID, semun) == -1)
+       elog(NOTICE, "IPCPrivateSemaphoreKill: semctl(%d, 0, IPC_RMID, ...) failed: %s",
+            semId, strerror(errno));
 }
 
 
@@ -261,8 +262,8 @@ IPCPrivateMemoryKill(int status,
    {
        if (shmctl(shmId, IPC_RMID, (struct shmid_ds *) NULL) < 0)
        {
-           elog(NOTICE, "IPCPrivateMemoryKill: shmctl(%d, %d, 0) failed: %m",
-                shmId, IPC_RMID);
+           elog(NOTICE, "IPCPrivateMemoryKill: shmctl(id=%d, IPC_RMID, NULL) failed: %m",
+                shmId);
        }
    }
 }
@@ -307,10 +308,19 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
 
        if (semId < 0)
        {
-           fprintf(stderr, "IpcSemaphoreCreate: semget(%d, %d, 0%o) failed: %s\n",
+           fprintf(stderr, "IpcSemaphoreCreate: semget(key=%d, num=%d, 0%o) failed: %s\n",
                    semKey, semNum, (unsigned)(permission|IPC_CREAT),
                    strerror(errno));
-           IpcConfigTip();
+
+           if (errno == ENOSPC)
+               fprintf(stderr,
+                       "\nThis error does *not* mean that you have run out of disk space.\n\n"
+                       "It occurs either because system limit for the maximum number of\n"
+                       "semaphore sets (SEMMNI), or the system wide maximum number of\n"
+                       "semaphores (SEMMNS), would be exceeded.  You need to raise the\n"
+                       "respective kernel parameter.  Look into the PostgreSQL documentation\n"
+                       "for details.\n\n");
+
            return (-1);
        }
        for (i = 0; i < semNum; i++)
@@ -319,10 +329,16 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
        errStatus = semctl(semId, 0, SETALL, semun);
        if (errStatus == -1)
        {
-           fprintf(stderr, "IpcSemaphoreCreate: semctl(id=%d) failed: %s\n",
+           fprintf(stderr, "IpcSemaphoreCreate: semctl(id=%d, 0, SETALL, ...) failed: %s\n",
                    semId, strerror(errno));
+
+           if (errno == ERANGE)
+               fprintf(stderr,
+                       "You possibly need to raise your kernel's SEMVMX value to be at least\n"
+                       "%d.  Look into the PostgreSQL documentation for details.\n",
+                       semStartValue);
+
            semctl(semId, 0, IPC_RMID, semun);
-           IpcConfigTip();
            return (-1);
        }
 
@@ -516,9 +532,35 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
 
    if (shmid < 0)
    {
-       fprintf(stderr, "IpcMemoryCreate: shmget(%d, %d, 0%o) failed: %s\n",
-               memKey, size, (unsigned)(IPC_CREAT|permission), strerror(errno));
-       IpcConfigTip();
+       fprintf(stderr, "IpcMemoryCreate: shmget(key=%d, size=%d, 0%o) failed: %s\n",
+               (int)memKey, size, (unsigned)(IPC_CREAT|permission),
+               strerror(errno));
+
+       if (errno == EINVAL)
+           fprintf(stderr,
+                   "\nThis error can be caused by one of three things:\n\n"
+                   "1. The maximum size for shared memory segments on your system was\n"
+                   "   exceeded.  You need to raise the SHMMAX parameter in your kernel\n"
+                   "   to be at least %d bytes.\n\n"
+                   "2. The requested shared memory segment was too small for your system.\n"
+                   "   You need to lower the SHMMIN parameter in your kernel.\n\n"
+                   "3. The requested shared memory segment already exists but is of the\n"
+                   "   wrong size.  This is most likely the case if an old version of\n"
+                   "   PostgreSQL crashed and didn't clean up.  The `ipcclean' utility\n"
+                   "   can be used to remedy this.\n\n"
+                   "The PostgreSQL Administrator's Guide contains more information about\n"
+                   "shared memory configuration.\n\n",
+                   size);
+
+       else if (errno == ENOSPC)
+           fprintf(stderr,
+                   "\nThis error does *not* mean that you have run out of disk space.\n\n"
+                   "It occurs either if all available shared memory ids have been taken,\n"
+                   "in which case you need to raise the SHMMNI parameter in your kernel,\n"
+                   "or because the system's overall limit for shared memory has been\n"
+                   "reached.  The PostgreSQL Administrator's Guide contains more\n"
+                   "information about shared memory configuration.\n\n");
+
        return IpcMemCreationFailed;
    }
 
@@ -541,7 +583,7 @@ IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
 
    if (shmid < 0)
    {
-       fprintf(stderr, "IpcMemoryIdGet: shmget(%d, %d, 0) failed: %s\n",
+       fprintf(stderr, "IpcMemoryIdGet: shmget(key=%d, size=%d, 0) failed: %s\n",
                memKey, size, strerror(errno));
        return IpcMemIdGetFailed;
    }
@@ -558,7 +600,7 @@ static void
 IpcMemoryDetach(int status, char *shmaddr)
 {
    if (shmdt(shmaddr) < 0)
-       elog(NOTICE, "IpcMemoryDetach: shmdt(0x%p): %m", shmaddr);
+       elog(NOTICE, "IpcMemoryDetach: shmdt(0x%p) failed: %m", shmaddr);
 }
 
 /****************************************************************************/
@@ -694,13 +736,3 @@ LockIsFree(int lockid)
 #endif
 
 #endif  /* HAS_TEST_AND_SET */
-
-static void
-IpcConfigTip(void)
-{
-   fprintf(stderr, "This type of error is usually caused by an improper\n");
-   fprintf(stderr, "shared memory or System V IPC semaphore configuration.\n");
-   fprintf(stderr, "For more information, see the FAQ and platform-specific\n");
-   fprintf(stderr, "FAQ's in the source directory pgsql/doc or on our\n");
-   fprintf(stderr, "web site at http://www.postgresql.org.\n");
-}