Thread: max_connections

max_connections

From
Joao Junior
Date:
Hi, 
I am not sure if here is the best place to post this.
I would like to know why  max_connections parameter can't be changed without a restart. I know that it is a postmaster's context parameter. 
Which  PostgreSQL's subsystems, structures and OS kernel parameters  should be affected to support this change??

Thanks!

Re: max_connections

From
Pavel Stehule
Date:
Hi

út 22. 10. 2019 v 14:28 odesílatel Joao Junior <jcoj2006@gmail.com> napsal:
Hi, 
I am not sure if here is the best place to post this.
I would like to know why  max_connections parameter can't be changed without a restart. I know that it is a postmaster's context parameter. 
Which  PostgreSQL's subsystems, structures and OS kernel parameters  should be affected to support this change??

The max_connections is used more time inside PostgreSQL source code - typically for dimensions arrays where one field is per session.

You can search in source code the variable "MaxConnections". It's used for informations about sessions (processes), about transactions, locks, ..

Unfortunately, lot of these arrays are allocated in shared memory. For shared memory has Postgres special coding standards - almost all memory is allocated in startup time, and newer released. It is very simple to manage memory with these rules. It is fast, and there are not any risk of memory leaks. But related limits requires restart. Usually it is not a problem. So necessity of restart after change of max_connection is related to simple but very robust share memory management.

Regards

Pavel


Thanks!