Skip site navigation (1) Skip section navigation (2)

SHMMAX problem - how much is needed?

From: Laszlo Nagy <gandalf(at)shopzeus(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: SHMMAX problem - how much is needed?
Date: 2007-11-13 20:00:02
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
  Hi All,

I tried to follow the instructions that are described here:

My values config are:

page size = 4096

I'm using FreeBSD 6.2 and I have a test machine with 1GB memory. I would 
like to use 25% (256MB) as shared memory.

Here is what I have calculated (Python syntax, but probably everybody 
will understand):

shmmin = \
    parvalues['max_connections']*(400 + 
220*parvalues['max_locks_per_transaction']) +\
    parvalues['max_prepared_transactions']*(600 + 
220*parvalues['max_locks_per_transaction']) +\
    parvalues['shared_buffers']*parvalues['BLCKSZ']*8300 +\
    parvalues['wal_buffers']*parvalues['BLCKSZ']*8200 +\
    parvalues['max_fsm_relations']*70 +\
    500*1024 # From the docs: As a rough approximation, you can estimate 
the required segment size as 500 kB plus the variable amounts shown in 
the table.

The result for this was:

Minimum shared mem:  140731400 bytes = 135.0 MB
Maximum shared mem:  268435456 bytes = 256.0 MB

So far I put these values in /boot/loader.conf  (they were also 
calculated, I followed the recommendations in the docs):


After rebooted I got this message:

Nov 13 20:46:19 neptunus postgres[669]: [1-1] FATAL:  could not create 
shared memory segment: Invalid argument
Nov 13 20:46:19 neptunus postgres[669]: [1-2] DETAIL:  Failed system 
call was shmget(key=5432001, size=21725184, 03600).
Nov 13 20:46:19 neptunus postgres[669]: [1-3] HINT:  This error usually 
means that PostgreSQL's request for a shared memory segment exceeded 
your kernel's SHMMAX parameter.
Nov 13 20:46:19 neptunus postgres[669]: [1-4]  You can either reduce the 
request size or reconfigure the kernel with larger SHMMAX.  To reduce 
the request size (currently
Nov 13 20:46:19 neptunus postgres[669]: [1-5]  21725184 bytes), reduce 
PostgreSQL's shared_buffers parameter (currently 2048) and/or its 
max_connections parameter (currently
Nov 13 20:46:19 neptunus postgres[669]: [1-6]  50).
Nov 13 20:46:19 neptunus postgres[669]: [1-7]   If the request size is 
already small, it's possible that it is less than your kernel's SHMMIN 
parameter, in which case raising
Nov 13 20:46:19 neptunus postgres[669]: [1-8]  the request size or 
reconfiguring SHMMIN is called for.

What is wrong with my calculation?

The reason for this question: I'm writing a program that reads some 
input parameters (PostgreSQL and kernel configuration parameters), 
queries the computer for kernel page size, total available memory etc. 
and finally it calculates sysctl values.

This is not a toy: I have a server with memory problems and I would also 
like to find the optimal settings. (e.g. keep shared memory in physical 
memory, optimize for performance, but do not reserve more memory than 
needed). I would also like to contribute this program so other beginners 
will be able to set these parameters easily. My idea was that this 
program would warn me whenever there is a problem (e.g. SHMMIN > SHMMAX) 
but apparently I could not understand the basics and I failed to write 
the calculations.




pgsql-admin by date

Next:From: Bruce MomjianDate: 2007-11-13 20:10:23
Subject: Re: where can I find doc for pg_buffercache?
Previous:From: dx k9Date: 2007-11-13 19:54:10
Subject: effective_cache_size v824

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group