Re-implementation of PROXYSQL PAUSE and RESUME

pull/1056/head
René Cannaò 9 years ago
parent 3c6a323ada
commit 757f55791d

1
.gitignore vendored

@ -106,6 +106,7 @@ deps/pcre/pcre/
deps/protobuf/protobuf-2.6.1/
deps/sqlite3/sqlite-amalgamation-3150000/
deps/sqlite3/sqlite-amalgamation-3190200/
test/.vagrant
.DS_Store

@ -434,8 +434,7 @@ int MySQL_Threads_Handler::listener_add(const char *iface) {
int MySQL_Threads_Handler::listener_del(const char *iface) {
int idx;
idx=MLM->find_idx(iface);
if (idx>-1) {
while ((idx=MLM->find_idx(iface)) >= 0) {
unsigned int i;
int fd=MLM->get_fd(idx);
for (i=0;i<num_threads;i++) {
@ -450,7 +449,6 @@ int MySQL_Threads_Handler::listener_del(const char *iface) {
shutdown(fd,SHUT_RDWR);
close(fd);
}
return 0;
}

@ -444,15 +444,20 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
}
}
if (proxysql_mysql_paused==false) {
old_wait_timeout=GloMTH->get_variable_int((char *)"wait_timeout");
GloMTH->set_variable((char *)"wait_timeout",(char *)"0");
// to speed up this process we first change poll_timeout to 10
// MySQL_thread will call poll() with a maximum timeout of 10ms
old_wait_timeout=GloMTH->get_variable_int((char *)"poll_timeout");
GloMTH->set_variable((char *)"poll_timeout",(char *)"10");
GloMTH->commit();
// to speed up this process we first change wait_timeout to 0
// MySQL_thread will call poll() with a maximum timeout of 100ms
GloMTH->signal_all_threads(0);
GloMTH->stop_listeners();
proxysql_mysql_paused=true;
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL);
// we now rollback poll_timeout
char buf[32];
sprintf(buf,"%d",old_wait_timeout);
GloMTH->set_variable((char *)"poll_timeout",buf);
GloMTH->commit();
} else {
SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char *)"ProxySQL MySQL module is already paused, impossible to pause");
}
@ -469,14 +474,24 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
}
}
if (proxysql_mysql_paused==true) {
// to speed up the process we add the listeners while poll() is called with a maximum timeout of of 100ms
// to speed up this process we first change poll_timeout to 10
// MySQL_thread will call poll() with a maximum timeout of 10ms
old_wait_timeout=GloMTH->get_variable_int((char *)"poll_timeout");
GloMTH->set_variable((char *)"poll_timeout",(char *)"10");
GloMTH->commit();
GloMTH->signal_all_threads(0);
GloMTH->start_listeners();
//char buf[32];
//sprintf(buf,"%d",old_wait_timeout);
//GloMTH->set_variable((char *)"poll_timeout",buf);
//GloMTH->commit();
proxysql_mysql_paused=false;
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL);
// we now rollback poll_timeout
char buf[32];
sprintf(buf,"%d",old_wait_timeout);
GloMTH->set_variable((char *)"wait_timeout",buf);
GloMTH->set_variable((char *)"poll_timeout",buf);
GloMTH->commit();
proxysql_mysql_paused=false;
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL);
} else {
SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char *)"ProxySQL MySQL module is not paused, impossible to resume");
}

Loading…
Cancel
Save