diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index c6b9e150c..c63ad7264 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -2341,13 +2341,14 @@ MySQL_Connection * MySrvConnList::get_random_MyConn(MySQL_Session *sess, bool ff i=fastrand()%l; } if (sess && sess->client_myds && sess->client_myds->myconn && sess->client_myds->myconn->userinfo) { - // try to match schemaname + // try to match schemaname AND username char *schema = sess->client_myds->myconn->userinfo->schemaname; + char *username = sess->client_myds->myconn->userinfo->username; bool conn_found = false; unsigned int k; for (k = i; conn_found == false && k < l; k++) { conn = (MySQL_Connection *)conns->index(k); - if (strcmp(conn->userinfo->schemaname,schema)==0) { + if (strcmp(conn->userinfo->schemaname,schema)==0 && strcmp(conn->userinfo->username,username)==0) { conn_found = true; i = k; } @@ -2355,7 +2356,7 @@ MySQL_Connection * MySrvConnList::get_random_MyConn(MySQL_Session *sess, bool ff if (conn_found == false ) { for (k = 0; conn_found == false && k < i; k++) { conn = (MySQL_Connection *)conns->index(k); - if (strcmp(conn->userinfo->schemaname,schema)==0) { + if (strcmp(conn->userinfo->schemaname,schema)==0 && strcmp(conn->userinfo->username,username)==0) { conn_found = true; i = k; } diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 0528898c7..4703a3bbe 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -5097,7 +5097,8 @@ MySQL_Connection * MySQL_Thread::get_MyConn_local(unsigned int _hid, MySQL_Sessi //npc++; if (sess && sess->client_myds && sess->client_myds->myconn && sess->client_myds->myconn->userinfo) { char *schema = sess->client_myds->myconn->userinfo->schemaname; - if (strcmp(c->userinfo->schemaname,schema)==0) { + char *username = sess->client_myds->myconn->userinfo->username; + if (strcmp(c->userinfo->schemaname,schema)==0 && strcmp(c->userinfo->username,username)==0) { c=(MySQL_Connection *)cached_connections->remove_index_fast(i); return c; } @@ -5125,7 +5126,8 @@ MySQL_Connection * MySQL_Thread::get_MyConn_local(unsigned int _hid, MySQL_Sessi npc++; if (sess && sess->client_myds && sess->client_myds->myconn && sess->client_myds->myconn->userinfo) { char *schema = sess->client_myds->myconn->userinfo->schemaname; - if (strcmp(c->userinfo->schemaname,schema)==0) { + char *username = sess->client_myds->myconn->userinfo->username; + if (strcmp(c->userinfo->schemaname,schema)==0 && strcmp(c->userinfo->username,username)==0) { c=(MySQL_Connection *)cached_connections->remove_index_fast(i); return c; }