Merge pull request #2637 from sysown/v2.0.11-warmup

V2.0.11 warmup
pull/2671/head
René Cannaò 6 years ago committed by GitHub
commit 7dd76aed94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -293,6 +293,7 @@ class MySQL_Threads_Handler
int shun_recovery_time_sec;
int query_retries_on_failure;
bool client_multi_statements;
bool connection_warming;
int connect_retries_on_failure;
int connect_retries_delay;
int connection_delay_multiplex_ms;

@ -710,6 +710,7 @@ __thread unsigned int mysql_thread___default_charset;
__thread unsigned int mysql_thread___handle_unknown_charset;
__thread int mysql_thread___poll_timeout;
__thread int mysql_thread___poll_timeout_on_failure;
__thread bool mysql_thread___connection_warming;
__thread bool mysql_thread___have_compress;
__thread bool mysql_thread___have_ssl;
__thread bool mysql_thread___client_found_rows;
@ -865,6 +866,7 @@ extern __thread unsigned int mysql_thread___default_charset;
extern __thread unsigned int mysql_thread___handle_unknown_charset;
extern __thread int mysql_thread___poll_timeout;
extern __thread int mysql_thread___poll_timeout_on_failure;
extern __thread bool mysql_thread___connection_warming;
extern __thread bool mysql_thread___have_compress;
extern __thread bool mysql_thread___have_ssl;
extern __thread bool mysql_thread___client_found_rows;

@ -2684,7 +2684,15 @@ MySQL_Connection * MySrvConnList::get_random_MyConn(MySQL_Session *sess, bool ff
MySQL_Connection * conn=NULL;
unsigned int i;
unsigned int l=conns_length();
if (l && ff==false) {
bool needs_warming = false;
if (mysql_thread___connection_warming) {
unsigned int total_connections = mysrvc->ConnectionsFree->conns_length()+mysrvc->ConnectionsUsed->conns_length();
unsigned int expected_warm_connections = mysql_thread___free_connections_pct*mysrvc->max_connections/100;
if (total_connections < expected_warm_connections) {
needs_warming = true;
}
}
if (l && ff==false && needs_warming==false) {
if (l>32768) {
i=rand()%l;
} else {

@ -354,6 +354,7 @@ static char * mysql_thread_variables_names[]= {
(char *)"default_charset",
(char *)"handle_unknown_charset",
(char *)"free_connections_pct",
(char *)"connection_warming",
#ifdef IDLE_THREADS
(char *)"session_idle_ms",
#endif // IDLE_THREADS
@ -564,6 +565,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
variables.wait_timeout=8*3600*1000;
variables.throttle_max_bytes_per_second_to_client=0;
variables.throttle_ratio_server_to_client=0;
variables.connection_warming=false;
variables.max_connections=10*1000;
variables.max_stmts_per_connection=20;
variables.max_stmts_cache=10000;
@ -983,6 +985,7 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) {
if (!strcmp(name,"connect_timeout_server_max")) return (int)variables.connect_timeout_server_max;
if (!strcmp(name,"connection_delay_multiplex_ms")) return (int)variables.connection_delay_multiplex_ms;
if (!strcmp(name,"connection_max_age_ms")) return (int)variables.connection_max_age_ms;
if (!strcmp(name,"connection_warming")) return (int)variables.connection_warming;
if (!strcmp(name,"connpoll_reset_queue_length")) return (int)variables.connpoll_reset_queue_length;
}
break;
@ -1636,6 +1639,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f
if (!strcasecmp(name,"forward_autocommit")) {
return strdup((variables.forward_autocommit ? "true" : "false"));
}
if (!strcasecmp(name,"connection_warming")) {
return strdup((variables.connection_warming ? "true" : "false"));
}
if (!strcasecmp(name,"enforce_autocommit_on_reads")) {
return strdup((variables.enforce_autocommit_on_reads ? "true" : "false"));
}
@ -3145,6 +3151,17 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t
}
return false;
}
if (!strcasecmp(name,"connection_warming")) {
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.connection_warming=true;
return true;
}
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
variables.connection_warming=false;
return true;
}
return false;
}
#ifdef IDLE_THREADS
if (!strcasecmp(name,"session_idle_show_processlist")) {
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
@ -4797,6 +4814,7 @@ void MySQL_Thread::refresh_variables() {
mysql_thread___client_found_rows=(bool)GloMTH->get_variable_int((char *)"client_found_rows");
mysql_thread___multiplexing=(bool)GloMTH->get_variable_int((char *)"multiplexing");
mysql_thread___log_unhealthy_connections=(bool)GloMTH->get_variable_int((char *)"log_unhealthy_connections");
mysql_thread___connection_warming=(bool)GloMTH->get_variable_int((char*)"connection_warming");
mysql_thread___forward_autocommit=(bool)GloMTH->get_variable_int((char *)"forward_autocommit");
mysql_thread___enforce_autocommit_on_reads=(bool)GloMTH->get_variable_int((char *)"enforce_autocommit_on_reads");
mysql_thread___autocommit_false_not_reusable=(bool)GloMTH->get_variable_int((char *)"autocommit_false_not_reusable");

Loading…
Cancel
Save