Bug #84275 system status Max_used_connections show error message
Submitted: 20 Dec 2016 12:16 Modified: 20 Dec 2016 12:53
Reporter: slwang wang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Connection Handling Severity:S3 (Non-critical)
Version:5.7.17 OS:CentOS
Assigned to: CPU Architecture:Any
Tags: system status;Max_used_connections;

[20 Dec 2016 12:16] slwang wang
Description:
The client which uses normal user without super privileges connects to mysql server failed due to `too many connection`. The system global status `Max_used_connections` will show error message.Its value is one more than expected. 

How to repeat:
1. Create Normal user `test` which has no super privilege.
2. Set global max_connections= 2
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 2     |
+-----------------+-------+
3. Using three clients which user are `test` to connect to server.
4. The third client will connect failed due to `too many connection`
5. show global status like "Max_used_connections"
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 3     |
+----------------------+-------+
6. The value of `Max_used_connections` is 3. But the value we expected is 2. 

Suggested fix:
When the number of connections reaches the the value of `max_connections`.The server will retain a free connection for the user which has super privilege.When the normal user connect to server, the value of status `Max_used_connections` will increment and the connection will fail. 

When the connection fails because it has no super privilege, we expect the value of status `Max_used_connections`reducing to correct value.

Or updating the value of status `Max_used_connections` after executing function `acl_authenticate` success instead of function `Connection_handler_manager::check_and_incr_conn_count`.
[20 Dec 2016 12:53] MySQL Verification Team
Hello slwang wang,

Thank you for the report.

Thanks,
Umesh