From cfe1c7ff726ad20b85549ada8286a2cba60a8466 Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Thu, 14 Mar 2019 23:18:52 +0800 Subject: [PATCH] No throttle when throttle_max_bytes_per_second_to_client == 0 If throttle_max_bytes_per_second_to_client == 0, disable throttling. This matches the mysql convention of 0 == no limit. Change the default to 0. --- lib/MySQL_Session.cpp | 5 +++-- lib/MySQL_Thread.cpp | 4 ++-- lib/mysql_connection.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index ca2b62a8d0..aa5ed8ce11 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -467,6 +467,7 @@ void MySQL_Session::writeout() { int tps = 10; // throttling per second , by default every 100ms int total_written = 0; unsigned long long last_sent_=0; + bool disable_throttle = mysql_thread___throttle_max_bytes_per_second_to_client == 0; int mwpl = mysql_thread___throttle_max_bytes_per_second_to_client; // max writes per call mwpl = mwpl/tps; if (client_myds) client_myds->array2buffer_full(); @@ -492,7 +493,7 @@ void MySQL_Session::writeout() { if (retbytes==QUEUE_T_DEFAULT_SIZE) { // optimization to solve memory bloat runloop=true; } - while (runloop && total_written < mwpl) { + while (runloop && (disable_throttle || total_written < mwpl)) { runloop=false; // the default client_myds->array2buffer_full(); struct pollfd fds; @@ -514,7 +515,7 @@ void MySQL_Session::writeout() { } // flow control - if (total_written > 0) { + if (!disable_throttle && total_written > 0) { if (total_written > mwpl) { unsigned long long add_ = 1000000/tps + 1000000/tps*((unsigned long long)total_written - (unsigned long long)mwpl)/mwpl; pause_until = thread->curtime + add_; diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index dea7d79b01..44766e2ebf 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -394,7 +394,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() { variables.query_digests_max_digest_length=2*1024; variables.query_digests_max_query_length=65000; // legacy default variables.wait_timeout=8*3600*1000; - variables.throttle_max_bytes_per_second_to_client=2147483647; + variables.throttle_max_bytes_per_second_to_client=0; variables.throttle_ratio_server_to_client=0; variables.max_connections=10*1000; variables.max_stmts_per_connection=20; @@ -1629,7 +1629,7 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t #endif // IDLE_THREADS if (!strcasecmp(name,"throttle_max_bytes_per_second_to_client")) { int intv=atoi(value); - if (intv >= 1024 && intv <= 2147483647) { + if (intv >= 0 && intv <= 2147483647) { variables.throttle_max_bytes_per_second_to_client=intv; return true; } else { diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 46c1c4e2a0..dd63058058 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -1024,7 +1024,7 @@ MDB_ASYNC_ST MySQL_Connection::handler(short event) { if ( (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*8) || - ( mysql_thread___throttle_ratio_server_to_client && (processed_bytes > (unsigned long long)mysql_thread___throttle_max_bytes_per_second_to_client/10*(unsigned long long)mysql_thread___throttle_ratio_server_to_client) ) + ( mysql_thread___throttle_ratio_server_to_client && mysql_thread___throttle_max_bytes_per_second_to_client && (processed_bytes > (unsigned long long)mysql_thread___throttle_max_bytes_per_second_to_client/10*(unsigned long long)mysql_thread___throttle_ratio_server_to_client) ) ) { next_event(ASYNC_USE_RESULT_CONT); // we temporarily pause } else {