Hello, I found that the formulas to calculate SEMMNI and SEMMNS are incorrect in 9.2 and later.
http://www.postgresql.org/docs/9.5/static/kernel-resources.html All of them say that the same thing as following, | SEMMNI Maximum number of semaphore identifiers (i.e., sets) | | at least ceil((max_connections + autovacuum_max_workers + 4) / 16) | | SEMMNS Maximum number of semaphores system-wide | | ceil((max_connections + autovacuum_max_workers + 4) / 16) * 17 | plus room for other applications But actually the number of semaphores PostgreSQL needs is calculated as following in 9.4 and later. numSemas = MaxConnections + NUM_AUXILIARY_PROCS(=4) MaxConnections = max_connections + autovacuum_max_workers + 1 + max_worker_processes So, the formula for SEMMNI should be ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16) and SEMMNS should have the same fix. In 9.3 and 9.2, the documentation says the same thing but actually it is calculated as following, numSemas = MaxConnections + NUM_AUXILIARY_PROCS(=4) MaxConnections = max_connections + autovacuum_max_workers + 1 + GetNumShmemAttachedBgworkers() Omitting GetNumShmemAttachedBgworkers, the actual formula is ceil((max_connections + autovacuum_max_workers + 5) / 16) In 9.1, NUM_AUXILIARY_PROCS is 3 so the documentations is correct. I attached two patches for 9.2-9.3 and 9.4-9.6dev respectively. patch command complains a bit on applying it on 9.2. On the platforforms that doesn't have tas operation needs additional 1024 + 64 semaphores but I understand it as out of scope of the documentation. One concern is that 'at least' and 'plus room for other applications' are mixed in the table 17-1, especially for SEMMNI and SEMMNS. It seems to me that they should be in the same wording, but it is not an actual problem. regards, -- Kyotaro Horiguchi NTT Open Source Software Center
>From 6da5ad413dff4724fee75f1ba09013b6033f76ca Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi <horiguchi.kyot...@lab.ntt.co.jp> Date: Wed, 3 Feb 2016 11:35:43 +0900 Subject: [PATCH] Fix the formula to calculate SEMMNI and SEMMNS in documentation --- doc/src/sgml/runtime.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 0db3807..45579da 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -645,13 +645,13 @@ psql: could not connect to server: No such file or directory <row> <entry><varname>SEMMNI</></> <entry>Maximum number of semaphore identifiers (i.e., sets)</> - <entry>at least <literal>ceil((max_connections + autovacuum_max_workers + 4) / 16)</literal></> + <entry>at least <literal>ceil((max_connections + autovacuum_max_workers + 5) / 16)</literal></> </row> <row> <entry><varname>SEMMNS</></> <entry>Maximum number of semaphores system-wide</> - <entry><literal>ceil((max_connections + autovacuum_max_workers + 4) / 16) * 17</literal> plus room for other applications</> + <entry><literal>ceil((max_connections + autovacuum_max_workers + 5) / 16) * 17</literal> plus room for other applications</> </row> <row> -- 1.8.3.1
>From aaf51a50e942edfa35af20a8a1d8b8719155664b Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi <horiguchi.kyot...@lab.ntt.co.jp> Date: Wed, 3 Feb 2016 11:19:58 +0900 Subject: [PATCH] Fix the formula to calculate SEMMNI and SEMMNS in documentation --- doc/src/sgml/runtime.sgml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 650d455..4b2e403 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -645,13 +645,13 @@ psql: could not connect to server: No such file or directory <row> <entry><varname>SEMMNI</></> <entry>Maximum number of semaphore identifiers (i.e., sets)</> - <entry>at least <literal>ceil((max_connections + autovacuum_max_workers + 4) / 16)</literal></> + <entry>at least <literal>ceil((max_connections + autovacuum_max_workers max_worker_processes + 5) / 16)</literal></> </row> <row> <entry><varname>SEMMNS</></> <entry>Maximum number of semaphores system-wide</> - <entry><literal>ceil((max_connections + autovacuum_max_workers + 4) / 16) * 17</literal> plus room for other applications</> + <entry><literal>ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16) * 17</literal> plus room for other applications</> </row> <row> -- 1.8.3.1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers