Merge pull request #3025 from sysown/v2.1.0-70061

V2.1.0 70061
v2.1.0-3042
René Cannaò 6 years ago committed by GitHub
commit dce513d311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
.gitignore vendored

@ -111,6 +111,7 @@ deps/libconfig/libconfig-1.7.2/
#libmicrohttpd
deps/libmicrohttpd/libmicrohttpd-0.9.55/
deps/libmicrohttpd/libmicrohttpd-0.9.68/
deps/libmicrohttpd/libmicrohttpd
#libhttpserver
deps/libhttpserver/libhttpserver-master_20191121/
@ -125,7 +126,9 @@ deps/lz4/lz4/
#re2
deps/re2/re2/
deps/re2/re2-2018-07-01/
deps/re2/re2-2020-07-06/
deps/pcre/pcre-8.39/
deps/pcre/pcre-8.44/
deps/pcre/pcre/
# curl
@ -152,6 +155,7 @@ deps/libev/libev-4.24/
deps/libssl/openssl-1.1.0h/
deps/libssl/openssl-1.1.1b/
deps/libssl/openssl-1.1.1d/
deps/libssl/openssl-1.1.1g/
#google coredumper
deps/google-coredumper/google-coredumper/

11
deps/Makefile vendored

@ -183,8 +183,8 @@ prometheus-cpp/prometheus-cpp/lib/libprometheus-cpp-core.a:
prometheus-cpp: prometheus-cpp/prometheus-cpp/lib/libprometheus-cpp-core.a
re2/re2/obj/libre2.a:
# cd re2 && rm -rf re2-2018-07-01
cd re2 && rm -rf re2-2020-07-06
cd re2 && rm -rf re2-2018-07-01 || true
cd re2 && rm -rf re2-2020-07-06 || true
# cd re2 && tar -zxf re2-20140304.tgz
cd re2 && tar -zxf re2.tar.gz
# cd re2/re2 && sed -i -e 's/-O3 -g /-O3 -fPIC /' Makefile
@ -195,6 +195,7 @@ re2/re2/obj/libre2.a:
re2: re2/re2/obj/libre2.a
pcre/pcre/.libs/libpcre.a:
cd pcre && rm -rf pcre-8.39
cd pcre && rm -rf pcre-8.44
cd pcre && tar -zxf pcre-8.44.tar.gz
cd pcre/pcre && ./configure
@ -220,8 +221,10 @@ cleanall:
cd mariadb-client-library && rm -rf mariadb-connector-c-3.0.2-src
cd mariadb-client-library && rm -rf mariadb-connector-c-3.1.4-src
cd libconfig && rm -rf libconfig-1.4.9
cd re2 && rm -rf re2-2020-07-06
cd pcre && rm -rf pcre-8.44
cd re2 && rm -rf re2-2018-07-01 || true
cd re2 && rm -rf re2-2020-07-06 || true
cd pcre && rm -rf pcre-8.39 || true
cd pcre && rm -rf pcre-8.44 || true
cd sqlite3/sqlite3 && rm -rf * || true
cd clickhouse-cpp/clickhouse-cpp && rm -rf * || true
cd lz4 && rm -rf lz4-1.7.5 || true

@ -404,6 +404,7 @@ class MySQL_Threads_Handler
int connect_retries_delay;
int connection_delay_multiplex_ms;
int connection_max_age_ms;
int connect_timeout_client;
int connect_timeout_server;
int connect_timeout_server_max;
int free_connections_pct;

@ -721,6 +721,7 @@ __thread int mysql_thread___connect_retries_on_failure;
__thread int mysql_thread___connect_retries_delay;
__thread int mysql_thread___connection_delay_multiplex_ms;
__thread int mysql_thread___connection_max_age_ms;
__thread int mysql_thread___connect_timeout_client;
__thread int mysql_thread___connect_timeout_server;
__thread int mysql_thread___connect_timeout_server_max;
__thread int mysql_thread___query_processor_iterations;
@ -867,6 +868,7 @@ extern __thread int mysql_thread___connect_retries_on_failure;
extern __thread int mysql_thread___connect_retries_delay;
extern __thread int mysql_thread___connection_delay_multiplex_ms;
extern __thread int mysql_thread___connection_max_age_ms;
extern __thread int mysql_thread___connect_timeout_client;
extern __thread int mysql_thread___connect_timeout_server;
extern __thread int mysql_thread___connect_timeout_server_max;
extern __thread int mysql_thread___query_processor_iterations;

@ -6147,13 +6147,17 @@ int MySQL_Session::FindOneActiveTransaction() {
}
unsigned long long MySQL_Session::IdleTime() {
if (client_myds==0) return 0;
if (status!=WAITING_CLIENT_DATA) return 0;
int idx=client_myds->poll_fds_idx;
unsigned long long last_sent=thread->mypolls.last_sent[idx];
unsigned long long last_recv=thread->mypolls.last_recv[idx];
unsigned long long last_time=(last_sent > last_recv ? last_sent : last_recv);
return thread->curtime - last_time;
unsigned long long ret = 0;
if (client_myds==0) return 0;
if (status!=WAITING_CLIENT_DATA && status!=CONNECTING_CLIENT) return 0;
int idx=client_myds->poll_fds_idx;
unsigned long long last_sent=thread->mypolls.last_sent[idx];
unsigned long long last_recv=thread->mypolls.last_recv[idx];
unsigned long long last_time=(last_sent > last_recv ? last_sent : last_recv);
if (thread->curtime > last_time) {
ret = thread->curtime - last_time;
}
return ret;
}

@ -406,6 +406,7 @@ static char * mysql_thread_variables_names[]= {
(char *)"connect_retries_delay",
(char *)"connection_delay_multiplex_ms",
(char *)"connection_max_age_ms",
(char *)"connect_timeout_client",
(char *)"connect_timeout_server",
(char *)"connect_timeout_server_max",
(char *)"eventslog_filename",
@ -989,6 +990,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
variables.connect_retries_on_failure=10;
variables.connection_delay_multiplex_ms=0;
variables.connection_max_age_ms=0;
variables.connect_timeout_client=10000;
variables.connect_timeout_server=1000;
variables.connect_timeout_server_max=10000;
variables.free_connections_pct=10;
@ -1397,6 +1399,7 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) {
if (!strcmp(name,"commands_stats")) return (int)variables.commands_stats;
if (!strcmp(name,"connect_retries_delay")) return (int)variables.connect_retries_delay;
if (!strcmp(name,"connect_retries_on_failure")) return (int)variables.connect_retries_on_failure;
if (!strcmp(name,"connect_timeout_client")) return (int)variables.connect_timeout_client;
if (!strcmp(name,"connect_timeout_server")) return (int)variables.connect_timeout_server;
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;
@ -1778,6 +1781,10 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f
sprintf(intbuf,"%d",variables.connection_max_age_ms);
return strdup(intbuf);
}
if (!strcasecmp(name,"connect_timeout_client")) {
sprintf(intbuf,"%d",variables.connect_timeout_client);
return strdup(intbuf);
}
if (!strcasecmp(name,"connect_timeout_server")) {
sprintf(intbuf,"%d",variables.connect_timeout_server);
return strdup(intbuf);
@ -2777,6 +2784,15 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi
return false;
}
}
if (!strcasecmp(name,"connect_timeout_client")) {
int intv=atoi(value);
if (intv >= 500 && intv <= 3600*1000) {
variables.connect_timeout_client=intv;
return true;
} else {
return false;
}
}
if (!strcasecmp(name,"connect_timeout_server")) {
int intv=atoi(value);
if (intv >= 10 && intv <= 120*1000) {
@ -4313,7 +4329,7 @@ void MySQL_Thread::idle_thread_to_kill_idle_sessions() {
for (i=0;i<SESS_TO_SCAN && mysess_idx < mysql_sessions->len; i++) {
uint32_t sess_pos=mysess_idx;
MySQL_Session *mysess=(MySQL_Session *)mysql_sessions->index(sess_pos);
if (mysess->idle_since < min_idle) {
if (mysess->idle_since < min_idle || mysess->killed==true) {
mysess->killed=true;
MySQL_Data_Stream *tmp_myds=mysess->client_myds;
int dsidx=tmp_myds->poll_fds_idx;
@ -4631,6 +4647,13 @@ void MySQL_Thread::process_all_sessions() {
continue;
}
}
if (sess->status == CONNECTING_CLIENT) {
unsigned long long sess_time = sess->IdleTime();
if (sess_time/1000 > (unsigned long long)mysql_thread___connect_timeout_client) {
proxy_warning("Closing not established client connection %s:%d after %llums\n",sess->client_myds->addr.addr,sess->client_myds->addr.port, sess_time/1000);
sess->healthy = 0;
}
}
if (maintenance_loop) {
unsigned int numTrx=0;
unsigned long long sess_time = sess->IdleTime();
@ -4777,6 +4800,7 @@ void MySQL_Thread::refresh_variables() {
mysql_thread___client_multi_statements=(bool)GloMTH->get_variable_int((char *)"client_multi_statements");
mysql_thread___connection_delay_multiplex_ms=GloMTH->get_variable_int((char *)"connection_delay_multiplex_ms");
mysql_thread___connection_max_age_ms=GloMTH->get_variable_int((char *)"connection_max_age_ms");
mysql_thread___connect_timeout_client=GloMTH->get_variable_int((char *)"connect_timeout_client");
mysql_thread___connect_timeout_server=GloMTH->get_variable_int((char *)"connect_timeout_server");
mysql_thread___connect_timeout_server_max=GloMTH->get_variable_int((char *)"connect_timeout_server_max");
mysql_thread___free_connections_pct=GloMTH->get_variable_int((char *)"free_connections_pct");

Loading…
Cancel
Save