Bug #6100 connection limits
Submitted: 14 Oct 2004 14:45 Modified: 8 Feb 2006 12:25
Reporter: Eric Robibaro Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Security: Privileges Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any
Triage: Triaged: D5 (Feature request)

[14 Oct 2004 14:45] Eric Robibaro
In mysql there is a global limit on concurrent mysql connections, can we get an equivalent per-user limit please?
I'd really like to be able to prevent one user from using up the 500 connections all by himself in a virtual hosting environment.

How to repeat:
Feature request, not repeatable, but here is a likely scenario:

Server is used for virtual hosting, has 40 defined users, user root has unlimited concurrent connexions, server is limited to 400 concurrent.
user A is a newbie to php, and only uses pconnect, and his script leaks connections, probably due to non-thread safety.
user B is a consciencious user, and he only needs one connection.

Right now, user A prevents B from getting any connections, the minute he gets to 400.  Root is limited to one connection.

Suggested fix:
Add a new field for concurrent connections in mysql database's user table, conc_connect, and populate it with zeros by default.
Add code that checks not only per-server concurrency limits, but per-user.
Everyone in the plesk/hsphere/cpanel/ensim/direct admin/dtc/serverworx/virtualmin worlds rejoices after adding a minimal amount of code to their panels, and upgrading to the newer, latest mysql.
This was of course, an idealized scenario.
[8 Feb 2006 12:25] Valeriy Kravchuk
Thank you for a reasonable feature request.
[8 Feb 2006 17:16] Jim Winstead
Note that you can specify a maximum number of connections per user using the MAX CONNECTIONS option to GRANT.

What would be useful is a way to specify a default maximum number of connections per user.

Adding this should simply be a matter of adding a new server variable and adding an additional check in check_for_max_user_connections() in sql/sql_parse.cc.
[9 Dec 2009 5:13] Andrew Dalgleish
See also bugs 6108, 21040, 49549