Bug #32066 max_connections may be changed online
Submitted: 2 Nov 2007 22:33 Modified: 7 Nov 2007 12:17
Reporter: Grigory Rubtsov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:all OS:Any
Assigned to: Jon Stephens CPU Architecture:Any
Tags: max_connections, too many connections

[2 Nov 2007 22:33] Grigory Rubtsov
Description:
Manual says "If you need to support more connections, you should restart mysqld with a larger value for this variable."

http://dev.mysql.com/doc/refman/5.1/en/too-many-connections.html

But actually the number of connections may be changed online via global variable.

How to repeat:
mysql> set @@global.max_connections=111; SELECT VERSION();
Query OK, 0 rows affected (0.00 sec)

+-------------------------+
| VERSION()               |
+-------------------------+
| 5.1.22-rc-community-log | 
+-------------------------+
1 row in set (0.00 sec)
[3 Nov 2007 11:56] Jon Stephens
Reviewer:

Please verify that:

1. The new number of connections actually takes effect without restarting the server.

2. That the observed behaviour is expected, and not a server bug.

I've changed the category to Server pending the outcome.
[3 Nov 2007 12:38] Grigory Rubtsov
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.22    | 
+-----------+

mysql> select @@global.max_connections;
+--------------------------+
| @@global.max_connections |
+--------------------------+
|                      100 | 
+--------------------------+
1 row in set (0.01 sec)

mysql> set @@global.max_connections=2;
Query OK, 0 rows affected (0.00 sec)

[rgbeast@elf ~]$ mysql
[rgbeast@elf ~]$ mysql

mysql> show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host      | db   | Command | Time | State | Info             |
+----+------+-----------+------+---------+------+-------+------------------+
|  2 | root | localhost | NULL | Query   |    0 | NULL  | show processlist | 
|  3 | root | localhost | NULL | Sleep   |   36 | NULL  | NULL             | 
|  4 | root | localhost | NULL | Sleep   |   28 | NULL  | NULL             | 
+----+------+-----------+------+---------+------+-------+------------------+
3 rows in set (0.00 sec)

[rgbeast@elf ~]$ mysql
ERROR 1040 (00000): Too many connections

mysql> set @@global.max_connections=3;
Query OK, 0 rows affected (0.00 sec)

[rgbeast@elf ~]$ mysql

mysql> show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host      | db   | Command | Time | State | Info             |
+----+------+-----------+------+---------+------+-------+------------------+
|  2 | root | localhost | NULL | Query   |    0 | NULL  | show processlist | 
|  3 | root | localhost | NULL | Sleep   |   49 | NULL  | NULL             | 
|  4 | root | localhost | NULL | Sleep   |   41 | NULL  | NULL             | 
|  5 | root | localhost | NULL | Sleep   |    4 | NULL  | NULL             | 
+----+------+-----------+------+---------+------+-------+------------------+
4 rows in set (0.00 sec)

[rgbeast@elf ~]$ mysql
ERROR 1040 (00000): Too many connections

The behavior is like expected (one thing is that is allows max_connections+1 connections)
[6 Nov 2007 17:28] Valeriy Kravchuk
Other manual page, http://dev.mysql.com/doc/refman/5.1/en/dynamic-system-variables.html, clearly states that max_connection is dynamic and global system variable. So, this is definitely a reasonable documentation request in any case.
[7 Nov 2007 12:17] Jon Stephens
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.