From owner-freebsd-questions@FreeBSD.ORG Tue Nov 6 05:32:39 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0181FD01 for ; Tue, 6 Nov 2012 05:32:39 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from ipmail04.adl6.internode.on.net (ipmail04.adl6.internode.on.net [IPv6:2001:44b8:8060:ff02:300:1:6:4]) by mx1.freebsd.org (Postfix) with ESMTP id 32B098FC0A for ; Tue, 6 Nov 2012 05:32:37 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqAEAI2gmFDLevdH/2dsb2JhbABEv2mEVoIeAQEFHhpBEAsYCRMDDwkDAgECAUUGDQEHAQGIBapYkDyLfBWGQAOfRIZ7gwKBSQ Received: from ppp247-71.static.internode.on.net (HELO leader.local) ([203.122.247.71]) by ipmail04.adl6.internode.on.net with ESMTP; 06 Nov 2012 16:02:36 +1030 Message-ID: <50989F0C.8090509@ShaneWare.Biz> Date: Tue, 06 Nov 2012 15:54:28 +1030 From: Shane Ambler User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:16.0) Gecko/20121030 Thunderbird/16.0.2 MIME-Version: 1.0 To: Yuri Subject: Re: Why PostgreSQL doesn't start with shared_buffers=6GB ? References: <50970E35.6000600@rawbw.com> In-Reply-To: <50970E35.6000600@rawbw.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD Questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Nov 2012 05:32:39 -0000 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.