Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Nov 2012 15:54:28 +1030
From:      Shane Ambler <FreeBSD@ShaneWare.Biz>
To:        Yuri <yuri@rawbw.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Why PostgreSQL doesn't start with shared_buffers=6GB ?
Message-ID:  <50989F0C.8090509@ShaneWare.Biz>
In-Reply-To: <50970E35.6000600@rawbw.com>
References:  <50970E35.6000600@rawbw.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 05/11/2012 11:24, Yuri wrote:
> When I am setting shared_buffers=6GB in postgresql.conf it fails to start:
> DETAIL:  Failed system call was shmget(key=5432001, size=6612361216, 03600).
> even though kern.ipc.shmmax is set to ~7GB:
> $ sysctl -a | grep shm
> kern.ipc.shm_allow_removed: 0
> kern.ipc.shm_use_phys: 0
> kern.ipc.shmall: 1310720
> kern.ipc.shmseg: 128
> kern.ipc.shmmni: 192
> kern.ipc.shmmin: 1
> kern.ipc.shmmax: 7000000000
> kern.features.sysv_shm: 1
> kern.features.posix_shm: 1
>
> There are 17GB free memory as reported by top(1).
>
> Why shmget fails despite kern.ipc.shmmax is being high enough?
> Experimentally I found that shared_buffers=5GB also fails but 4GB
> succeeds. Is there another system limit on shmem besides kern.ipc.shmmax ?

Been a few years since I looked at my postgresql settings --

Per process --
kern.ipc.shmmax: Maximum shared memory segment size
kern.ipc.shmseg: Number of segments per process

segments relate to allocation requests not total allocations.
eg 4 segments of 2G would be ok but 1 segment of 8G not ok
Postgresql shared_buffers should be done in 1 allocation.

System wide --
kern.ipc.shmall: Maximum number of pages available for shared memory
kern.ipc.shmmni: Number of shared memory identifiers

kern.ipc.shmseg and kern.ipc.shmmni need to be set in /boot/loader.conf
not /etc/sysctl.conf

getconf PAGE_SIZE returns 4096

With a pagesize of 4K your kern.ipc.shmall would equate to a max of 5G
so you probably need to increase that. If you want postgresql to
allocate 6G then shmmax needs to be at least 6G and shmall needs to
be at least 6G/4K or 1572864

Remember that total shared memory allocation is not postgresql only -
you may need it higher than what postgresql needs.

Also of note - postgresql settings like temp_buffers are per client
connection and work_mem can be allocated several times for one query.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50989F0C.8090509>