Thread: Kernel Resources and max_connections

Kernel Resources and max_connections

From
Chris Hebrard
Date:
Hi,

I have postgres 8.0.2 installed on FreeBSD FreeBSD 4.11-RELEASE with 2GB
of RAM.

When trying to set max_connections=256 I get the following error message:

FATAL:  could not create semaphores: No space left on device
DETAIL:  Failed system call was semget(5432017, 17, 03600).
HINT:  This error does *not* mean that you have run out of disk space.
        It occurs when either the system limit for the maximum number of
semaphore sets (SEMMNI), or the system wide maximum number of semaphores
(SEMMNS), would be exceeded.  You need to raise the respective kernel
parameter.  Alternatively, reduce PostgreSQL's consumption of semaphores
by reducing its max_connections parameter (currently 256).
        The PostgreSQL documentation contains more information about
configuring your system for PostgreSQL.

I have read through the kernel resources documentation for postgres 8
and set values accordingly.
Some settings are not staying after a reboot, even if I place them in
/boot/loader.conf.

So far I'm able to get max_connections to 250.

Here is  a dump of  kern.ipc values:

kern.ipc.maxsockbuf: 262144
kern.ipc.sockbuf_waste_factor: 8
kern.ipc.somaxconn: 128
kern.ipc.max_linkhdr: 16
kern.ipc.max_protohdr: 60
kern.ipc.max_hdr: 76
kern.ipc.max_datalen: 136
kern.ipc.nmbclusters: 65536
kern.ipc.msgmax: 16384
kern.ipc.msgmni: 40
kern.ipc.msgmnb: 2048
kern.ipc.msgtql: 40
kern.ipc.msgssz: 8
kern.ipc.msgseg: 2048
kern.ipc.semmap: 30
kern.ipc.semmni: 256
kern.ipc.semmns: 272
kern.ipc.semmnu: 30
kern.ipc.semmsl: 60
kern.ipc.semopm: 100
kern.ipc.semume: 10
kern.ipc.semusz: 92
kern.ipc.semvmx: 32767
kern.ipc.semaem: 16384
kern.ipc.shmmax: 33554432
kern.ipc.shmmin: 1
kern.ipc.shmmni: 192
kern.ipc.shmseg: 128
kern.ipc.shmall: 8192
kern.ipc.shm_use_phys: 0
kern.ipc.shm_allow_removed: 0
kern.ipc.mbuf_wait: 32
kern.ipc.mbtypes: 38 551 3 0 0 0 0 0 0 0 0 0 0 0 0 0
kern.ipc.nmbufs: 262144
kern.ipc.nsfbufs: 8704
kern.ipc.nsfbufspeak: 7
kern.ipc.nsfbufsused: 0
kern.ipc.m_clreflimithits: 0
kern.ipc.mcl_pool_max: 0
kern.ipc.mcl_pool_now: 0
kern.ipc.maxsockets: 65536

And boot/loader.conf:

userconfig_script_load="YES"
kern.ipc.nmbclusters="65536"
kern.maxfiles="65536"
kern.maxfilesperproc="65536"
net.inet.tcp.mssdflt="1460"
kern.somaxconn="4096"
kern.ipc.semmns="272"
kern.ipc.semmni="256"
kern.ipc.shmmax="66099200"

kern.ipc.shmmax and kern.ipc.shmmin will not stay to what I set them to.

What am I doing wrong or not doing at all?

Your help is greatly appreciated.

Regards,
Chris.








--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005


Re: Kernel Resources and max_connections

From
Mark Kirkwood
Date:
Chris Hebrard wrote:

> kern.ipc.shmmax and kern.ipc.shmmin will not stay to what I set them to.
>
> What am I doing wrong or not doing at all?
>

These need to go in /etc/sysctl.conf. You might need to set shmall as well.

(This not-very-clear distinction between what is sysctl'abe and what is
a kernel tunable is a bit of a downer).

cheers

Mark



Re: Kernel Resources and max_connections

From
Chris Hebrard
Date:
Mark Kirkwood wrote:

> Chris Hebrard wrote:
>
>> kern.ipc.shmmax and kern.ipc.shmmin will not stay to what I set them to.
>>
>> What am I doing wrong or not doing at all?
>>
>
> These need to go in /etc/sysctl.conf. You might need to set shmall as
> well.
>
> (This not-very-clear distinction between what is sysctl'abe and what
> is a kernel tunable is a bit of a downer).
>
> cheers
>
> Mark
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>
>
Thanks for your reply,

I set the values in etc/sysctl.conf:

# $FreeBSD: src/etc/sysctl.conf,v 1.1.2.3 2002/04/15 00:44:13 dougb Exp $
#
#  This file is read when going to multi-user and its contents piped thru
#  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
#
# Added by IMP 2005-05-04
net.inet.tcp.rfc1323=1
kern.ipc.somaxconn=1024
kern.ipc.maxsockbuf=8388608
net.inet.tcp.sendspace=3217968
net.inet.tcp.recvspace=3217968
kern.ipc.semmns="272"
kern.ipc.semmni="256"
kern.ipc.shmmax="66099200"
kern.ipc.shmmin="256"


After a restart both shmmax and shmmin are now 0 and postgres failed to
start.

kern.ipc.maxsockbuf: 8388608
kern.ipc.sockbuf_waste_factor: 8
kern.ipc.somaxconn: 1024
kern.ipc.max_linkhdr: 16
kern.ipc.max_protohdr: 60
kern.ipc.max_hdr: 76
kern.ipc.max_datalen: 136
kern.ipc.nmbclusters: 65536
kern.ipc.msgmax: 16384
kern.ipc.msgmni: 40
kern.ipc.msgmnb: 2048
kern.ipc.msgtql: 40
kern.ipc.msgssz: 8
kern.ipc.msgseg: 2048
kern.ipc.semmap: 30
kern.ipc.semmni: 10
kern.ipc.semmns: 60
kern.ipc.semmnu: 30
kern.ipc.semmsl: 60
kern.ipc.semopm: 100
kern.ipc.semume: 10
kern.ipc.semusz: 92
kern.ipc.semvmx: 32767
kern.ipc.semaem: 16384
kern.ipc.shmmax: 0
kern.ipc.shmmin: 0
kern.ipc.shmmni: 192
kern.ipc.shmseg: 128
kern.ipc.shmall: 8192
kern.ipc.shm_use_phys: 0
kern.ipc.shm_allow_removed: 0
kern.ipc.mbuf_wait: 32
kern.ipc.mbtypes: 24 550 2 0 0 0 0 0 0 0 0 0 0 0 0 0
kern.ipc.nmbufs: 262144
kern.ipc.nsfbufs: 8704
kern.ipc.nsfbufspeak: 0
kern.ipc.nsfbufsused: 0
kern.ipc.m_clreflimithits: 0
kern.ipc.mcl_pool_max: 0
kern.ipc.mcl_pool_now: 0
kern.ipc.maxsockets: 65536

I'm lost here.
Chris.


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005


Re: Kernel Resources and max_connections

From
"Jim C. Nasby"
Date:
On Wed, May 04, 2005 at 01:46:34PM +1200, Mark Kirkwood wrote:
> (This not-very-clear distinction between what is sysctl'abe and what is
> a kernel tunable is a bit of a downer).

I think this is documented somewhere, though I can't think of where
right now.

Also, note that some sysctl's can only be set in /boot/loader.conf.
hw.ata.wc=0 is an example (which you want to set on any box with IDE
drives if you want fsync to actually do what it thinks it's doing).
--
Jim C. Nasby, Database Consultant               decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

Re: Kernel Resources and max_connections

From
Mark Kirkwood
Date:
Chris Hebrard wrote:
>
> I set the values in etc/sysctl.conf:
>
> # $FreeBSD: src/etc/sysctl.conf,v 1.1.2.3 2002/04/15 00:44:13 dougb Exp $
> #
> #  This file is read when going to multi-user and its contents piped thru
> #  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
> #
> # Added by IMP 2005-05-04
> net.inet.tcp.rfc1323=1
> kern.ipc.somaxconn=1024
> kern.ipc.maxsockbuf=8388608
> net.inet.tcp.sendspace=3217968
> net.inet.tcp.recvspace=3217968
> kern.ipc.semmns="272"
> kern.ipc.semmni="256"
> kern.ipc.shmmax="66099200"
> kern.ipc.shmmin="256"
>
>
> After a restart both shmmax and shmmin are now 0 and postgres failed to
> start.
>
>
Hmmm - puzzling. One point to check, did you take them out of
/boot/loader.conf ?

Assuming so, maybe don't quote 'em (see below).

Finally you need to to set shmall, otherwise it will over(under)ride the
shmmax setting. So try:

net.inet.tcp.rfc1323=1
kern.ipc.somaxconn=1024
kern.ipc.maxsockbuf=8388608
net.inet.tcp.sendspace=3217968
net.inet.tcp.recvspace=3217968
kern.ipc.semmns=272
kern.ipc.semmni=256
kern.ipc.shmmax=66099200
kern.ipc.shmmin=256
kern.ipc.shmall=32768