|
|
|
|
@ -3783,7 +3783,11 @@ void MySQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
|
|
|
|
|
}
|
|
|
|
|
int free_users=0;
|
|
|
|
|
int used_users=0;
|
|
|
|
|
if (session_type == PROXYSQL_SESSION_MYSQL || session_type == PROXYSQL_SESSION_CLICKHOUSE || session_type == PROXYSQL_SESSION_SQLITE) {
|
|
|
|
|
if (
|
|
|
|
|
( max_connections_reached == false )
|
|
|
|
|
&&
|
|
|
|
|
( session_type == PROXYSQL_SESSION_MYSQL || session_type == PROXYSQL_SESSION_CLICKHOUSE || session_type == PROXYSQL_SESSION_SQLITE)
|
|
|
|
|
) {
|
|
|
|
|
//if (session_type == PROXYSQL_SESSION_MYSQL || session_type == PROXYSQL_SESSION_CLICKHOUSE) {
|
|
|
|
|
client_authenticated=true;
|
|
|
|
|
switch (session_type) {
|
|
|
|
|
@ -3816,6 +3820,7 @@ void MySQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
|
|
|
|
|
if (max_connections_reached==true) {
|
|
|
|
|
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Too many connections\n");
|
|
|
|
|
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,_pid,1040,(char *)"08004", (char *)"Too many connections", true);
|
|
|
|
|
proxy_warning("mysql-max_connections reached. Returning 'Too many connections'\n");
|
|
|
|
|
__sync_fetch_and_add(&MyHGM->status.access_denied_max_connections, 1);
|
|
|
|
|
} else { // see issue #794
|
|
|
|
|
__sync_fetch_and_add(&MyHGM->status.access_denied_max_user_connections, 1);
|
|
|
|
|
@ -3824,6 +3829,7 @@ void MySQL_Session::handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(
|
|
|
|
|
char *b=(char *)malloc(strlen(a)+strlen(client_myds->myconn->userinfo->username)+16);
|
|
|
|
|
sprintf(b,a,client_myds->myconn->userinfo->username,used_users);
|
|
|
|
|
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,2,1226,(char *)"42000", b, true);
|
|
|
|
|
proxy_warning("User '%s' has exceeded the 'max_user_connections' resource (current value: %d)\n",client_myds->myconn->userinfo->username,used_users);
|
|
|
|
|
free(b);
|
|
|
|
|
}
|
|
|
|
|
__sync_add_and_fetch(&MyHGM->status.client_connections_aborted,1);
|
|
|
|
|
|