On Tue, 11 Nov 2008, Thom Brown wrote:
I've noticed that if I set my SHMMAX to 256 * 1024 * 1024 (268435456) and my shared_buffers value in postgresql.conf to 256MB the server fails to start. I managed to find a tipping point: 249MB seems to be too much and 248MB seems to be okay.
Buffers are allocated in 8K blocks. When you use '256MB', that turns into 32768 of those. Each buffer has a header and some other overhead such that they actually take up 8400 bytes[1], which totals 1.025X the amount that actually goes into the buffer pool. There's another MB or two that goes into other overhead, that part depends on things like max_connections. That overhead computation isn't even exact in the source code![2]
At shared_buffers=248MB, just the buffer pool overhead pushes the required amount to allocate up to 254.3MB; that just slips by with the rest of your settings. At 249MB, the buffer pool needs 255.3MB. With the other overhead added in, that just exceeds the 256MB SHMMAX and fails.
1: http://www.postgresql.org/docs/current/static/kernel-resources.html#SHARED-MEMORY-PARAMETERS 2: http://doxygen.postgresql.org/ipci_8c.html#5371eff96f6dea948021ddfc9f0f5a38 -- * Greg Smith gsmith@xxxxxxxxxxxxx http://www.gregsmith.com Baltimore, MD -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general