Skip to content

Commit

Permalink
No connection from pool for fast_forward #1157
Browse files Browse the repository at this point in the history
If a user is configured with fast_forward, no connection should be taken from the connection pool.
Yet the Hostgroup Manager should know about such connection.
  • Loading branch information
renecannao committed Sep 1, 2017
1 parent 0598c0d commit a22eb8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/MySQL_HostGroups_Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MySrvConnList {
conns->remove_index_fast((unsigned int)i);
}
MySQL_Connection *remove(int);
MySQL_Connection * get_random_MyConn();
MySQL_Connection * get_random_MyConn(bool ff);
unsigned int conns_length();
void drop_all_connections();
MySQL_Connection *index(unsigned int);
Expand Down Expand Up @@ -226,7 +226,7 @@ class MySQL_HostGroups_Manager {

void MyConn_add_to_pool(MySQL_Connection *);

MySQL_Connection * get_MyConn_from_pool(unsigned int);
MySQL_Connection * get_MyConn_from_pool(unsigned int, bool ff=false);

void drop_all_idle_connections();
int get_multiple_idle_connections(int, unsigned long long, MySQL_Connection **, int);
Expand Down
8 changes: 4 additions & 4 deletions lib/MySQL_HostGroups_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,11 +1363,11 @@ unsigned int MySrvList::cnt() {

MySrvC * MySrvList::idx(unsigned int i) { return (MySrvC *)servers->index(i); }

MySQL_Connection * MySrvConnList::get_random_MyConn() {
MySQL_Connection * MySrvConnList::get_random_MyConn(bool ff) {
MySQL_Connection * conn=NULL;
unsigned int i;
unsigned int l=conns_length();
if (l) {
if (l && ff==false) {
if (l>32768) {
i=rand()%l;
} else {
Expand All @@ -1386,14 +1386,14 @@ MySQL_Connection * MySrvConnList::get_random_MyConn() {
return NULL; // never reach here
}

MySQL_Connection * MySQL_HostGroups_Manager::get_MyConn_from_pool(unsigned int _hid) {
MySQL_Connection * MySQL_HostGroups_Manager::get_MyConn_from_pool(unsigned int _hid, bool ff) {
MySQL_Connection * conn=NULL;
wrlock();
status.myconnpoll_get++;
MyHGC *myhgc=MyHGC_lookup(_hid);
MySrvC *mysrvc=myhgc->get_random_MySrvC();
if (mysrvc) { // a MySrvC exists. If not, we return NULL = no targets
conn=mysrvc->ConnectionsFree->get_random_MyConn();
conn=mysrvc->ConnectionsFree->get_random_MyConn(ff);
mysrvc->ConnectionsUsed->add(conn);
status.myconnpoll_get_ok++;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3631,7 +3631,7 @@ void MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED
int i=100;
while (i) {
if (mc==NULL) {
mc=MyHGM->get_MyConn_from_pool(mybe->hostgroup_id);
mc=MyHGM->get_MyConn_from_pool(mybe->hostgroup_id, session_fast_forward);
}
if (mc) {
mybe->server_myds->attach_connection(mc);
Expand All @@ -3643,9 +3643,11 @@ void MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED
i--;
}
#else
mc=thread->get_MyConn_local(mybe->hostgroup_id); // experimental , #644
if (session_fast_forward == false) {
mc=thread->get_MyConn_local(mybe->hostgroup_id); // experimental , #644
}
if (mc==NULL) {
mc=MyHGM->get_MyConn_from_pool(mybe->hostgroup_id);
mc=MyHGM->get_MyConn_from_pool(mybe->hostgroup_id, session_fast_forward);
} else {
thread->status_variables.ConnPool_get_conn_immediate++;
}
Expand Down

0 comments on commit a22eb8b

Please sign in to comment.