Does the mysql parameter “max_connections” apply for unix socket connections?

Posted on

Question :

The documentation does not specify if max_connections apply only to TCP connections.

The way it is said, it looks like it does apply for any kind of connection, but I’d like to be sure because otherwise, I could use it when the “Too many connection” problem arises, even if the (last) SUPER connection slot is already in use.

Answer :

This limit applies to the total TCP socket connections and Unix socket connections, combined, so connecting via the Unix socket won’t help you if your connection count reaches the configured max.

However, the slot reserved for a user with SUPER privilege is not a single slot in the way your question implies. Any time the server’s current client thread count is equal to the value of max_connections, one more user with the SUPER privilege will be allowed to connect, regardless of how many SUPER connections are currently already established.

So the max+1 allowance refers not to a single slot that can be occupied and whose occupancy is remembered, but rather to an exception in the code that bypasses the logic that denies new connections connections when current == max and new attempt comes from a user with super, each time that condition is encountered.

This is one good reason, among others, that your application should never use an account with SUPER.

Leave a Reply

Your email address will not be published. Required fields are marked *