Merge pull request #1953 from carsonip/fix-throttle

No throttle when throttle_max_bytes_per_second_to_client == 0
pull/1926/head
René Cannaò 7 years ago committed by GitHub
commit 48e49a18e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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_;

@ -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 {

@ -1024,7 +1024,7 @@ handler_again:
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 {

Loading…
Cancel
Save