Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplexing incorrectly disabled after reuse a mysql_connection with auto_increment #1943

Closed
ahaha-zhang opened this issue Mar 9, 2019 · 2 comments

Comments

@ahaha-zhang
Copy link
Contributor

ahaha-zhang commented Mar 9, 2019

Hi Rene:
Version v1.4.16
I find that if a new connection reuses the mysql_connection with auto_increment, multiplexing is incorrectly disabled.
Since auto_increment_delay_token of the mysql_connection with auto_increment is not reset to zero when the mysql_connection is pushed back to ConnectionsFree list. Then new session which reuses the connection will be multiplexing disabled since MySQL_Connection::MultiplexDisabled() returns true.

Reproduce:
1.create a new session and back end connection:A.
2.insert into xxxx with auto_increment, thus,auto_increment_delay_token is set to 5 by default.
3.disconnect and connection A is pushed back to ConnectionsFree list.
4.create a new session and will reuse connection:A. The new session is multiplexing disabled.

Fix:
Reset connection->auto_increment_delay_token to zero when get new back end connection
MySQL_Connection * MySQL_HostGroups_Manager::get_MyConn_from_pool(unsigned int _hid, MySQL_Session *sess, 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(sess, ff);
if (conn) {
mysrvc->ConnectionsUsed->add(conn);
++conn->auto_increment_delay_token = 0;//reset auto_increment_delay_token of mysql_connection
status.myconnpoll_get_ok++;
}
}
wrunlock();
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySQL Connection %p, server %s:%d\n", conn, (conn ? conn->parent->address : "") , (conn ? conn->parent->port : 0 ));
return conn;
}

Thank you!

@renecannao
Copy link
Contributor

Thank you for the report.
Fixed in both 1.4.16 and 2.0.4 .
Note that the solution implemented is different than the suggested one.
auto_increment_delay_token is being reset to 0 in MySQL_Connection::reset() .

@ahaha-zhang
Copy link
Contributor Author

OK, thx :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants