From cb35d65d73a7e5de488528d884e925380affd5ef Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Tue, 22 Oct 2024 11:45:06 +0500 Subject: [PATCH] If query results needs to be cached, the mysql_thread___query_cache_size_MB setting takes precedence over mysql_thread___threshold_resultset_size --- lib/mysql_connection.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 42013c1d5..a2d91caa9 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -1531,8 +1531,15 @@ handler_again: } if (rows_read_inner > 1) { process_rows_in_ASYNC_STMT_EXECUTE_STORE_RESULT_CONT(processed_bytes); + + bool suspend_resultset_fetch = (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size * 8); + + if (suspend_resultset_fetch == true && myds->sess && myds->sess->qpo && myds->sess->qpo->cache_ttl > 0) { + suspend_resultset_fetch = (processed_bytes > ((uint64_t)mysql_thread___query_cache_size_MB) * 1024ULL * 1024ULL); + } + if ( - (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*8) + suspend_resultset_fetch || ( 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) ) ) { @@ -1738,8 +1745,15 @@ handler_again: myds->bytes_info.bytes_recv += br; bytes_info.bytes_recv += br; processed_bytes+=br; // issue #527 : this variable will store the amount of bytes processed during this event + + bool suspend_resultset_fetch = (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size * 8); + + if (suspend_resultset_fetch == true && myds->sess && myds->sess->qpo && myds->sess->qpo->cache_ttl > 0) { + suspend_resultset_fetch = (processed_bytes > ((uint64_t)mysql_thread___query_cache_size_MB) * 1024ULL * 1024ULL); + } + if ( - (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*8) + suspend_resultset_fetch || ( 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) ) ) {