diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 9bdf7b5e89..8370159e77 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -227,6 +227,15 @@ class MySrvC { // MySQL Server Container bool shunned_and_kill_all_connections; // if a serious failure is detected, this will cause all connections to die even if the server is just shunned int32_t use_ssl; char *comment; + + // 'server_backoff_time' stores a timestamp that prevents the server from being + // considered for random selection ('MyHGC::get_random_MySrvC') until that time passes. + // + // This is primarily used when `session_track_variables::ENFORCED` mode is active. + // If a server lacks the required capabilities in this mode, it is temporarily + // excluded from selection for a specified duration. + unsigned long long server_backoff_time; + MySrvConnList *ConnectionsUsed; MySrvConnList *ConnectionsFree; /** diff --git a/include/MySQL_Session.h b/include/MySQL_Session.h index 9d4d6fe395..8680fc967a 100644 --- a/include/MySQL_Session.h +++ b/include/MySQL_Session.h @@ -225,6 +225,36 @@ class MySQL_Session: public Base_Session&); void reduce_auto_increment_delay_token() { if (auto_increment_delay_token) auto_increment_delay_token--; }; bool match_ff_req_options(const MySQL_Connection *c); diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index ee5c096814..cee7fab3de 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -311,6 +311,8 @@ enum session_status { SETTING_NEXT_TRANSACTION_READ, PROCESSING_EXTENDED_QUERY_SYNC, RESYNCHRONIZING_CONNECTION, + SETTING_SESSION_TRACK_VARIABLES, + SETTING_SESSION_TRACK_STATE, session_status___NONE // special marker }; @@ -1305,6 +1307,7 @@ __thread int mysql_thread___client_host_error_counts; __thread int mysql_thread___handle_warnings; __thread int mysql_thread___evaluate_replication_lag_on_servers_load; __thread bool mysql_thread___ignore_min_gtid_annotations; +__thread int mysql_thread___session_track_variables; /* variables used for Query Cache */ __thread int mysql_thread___query_cache_size_MB; @@ -1609,6 +1612,7 @@ extern __thread int mysql_thread___client_host_error_counts; extern __thread int mysql_thread___handle_warnings; extern __thread int mysql_thread___evaluate_replication_lag_on_servers_load; extern __thread bool mysql_thread___ignore_min_gtid_annotations; +extern __thread int mysql_thread___session_track_variables; /* variables used for Query Cache */ extern __thread int mysql_thread___query_cache_size_MB; diff --git a/lib/MyHGC.cpp b/lib/MyHGC.cpp index 8af6956d17..8208f77073 100644 --- a/lib/MyHGC.cpp +++ b/lib/MyHGC.cpp @@ -38,6 +38,10 @@ MySrvC *MyHGC::get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_ for (j=0; jidx(j); if (mysrvc->get_status() == MYSQL_SERVER_STATUS_ONLINE) { // consider this server only if ONLINE + // skip servers that are in backoff period + if (mysrvc->server_backoff_time > sess->thread->curtime) + continue; + if (mysrvc->myhgc->num_online_servers.load(std::memory_order_relaxed) <= mysrvc->myhgc->attributes.max_num_online_servers) { // number of online servers in HG is within configured range if (mysrvc->ConnectionsUsed->conns_length() < mysrvc->max_connections) { // consider this server only if didn't reach max_connections if (mysrvc->current_latency_us < (mysrvc->max_latency_us ? mysrvc->max_latency_us : mysql_thread___default_max_latency_ms*1000)) { // consider the host only if not too far diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 1fdc87b4f8..fc04b61ca6 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -1908,10 +1908,12 @@ bool MySQL_Session::handler_again___verify_backend_session_track_gtids() { proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Session %p , client: %s , backend: %s\n", this, client_myds->myconn->options.session_track_gtids, mybe->server_myds->myconn->options.session_track_gtids); // we first verify that the backend supports it // if backend is old (or if it is not mysql) ignore this setting - if ((mybe->server_myds->myconn->mysql->server_capabilities & CLIENT_SESSION_TRACKING) == 0) { - // the backend doesn't support CLIENT_SESSION_TRACKING - return ret; // exit immediately + if ((mybe->server_myds->myconn->mysql->server_capabilities & CLIENT_SESSION_TRACKING) == 0 + || (mybe->server_myds->myconn->mysql->server_capabilities & CLIENT_DEPRECATE_EOF) == 0 + || mysql_thread___enable_server_deprecate_eof == false) { + return ret; } + uint32_t b_int = mybe->server_myds->myconn->options.session_track_gtids_int; uint32_t f_int = client_myds->myconn->options.session_track_gtids_int; @@ -1957,6 +1959,35 @@ bool MySQL_Session::handler_again___verify_backend_session_track_gtids() { return ret; } +bool MySQL_Session::handler_again___verify_backend_session_track_variables() { + int mode = mysql_thread___session_track_variables; + + // skip enabling session variable tracking in the following cases + if (mode == session_track_variables::DISABLED) { + return false; + } + if ((mybe->server_myds->myconn->mysql->server_capabilities & CLIENT_SESSION_TRACKING) == 0 + || (mybe->server_myds->myconn->mysql->server_capabilities & CLIENT_DEPRECATE_EOF) == 0) { + return false; + } + if (!mysql_thread___enable_server_deprecate_eof && mode != session_track_variables::ENFORCED) { + return false; + } + + // enable session tracking + if (mybe->server_myds->myconn->options.session_track_variables_sent == false) { + mybe->server_myds->myconn->options.session_track_variables_sent = true; + set_previous_status_mode3(); + NEXT_IMMEDIATE_NEW(SETTING_SESSION_TRACK_VARIABLES); + } + if (mybe->server_myds->myconn->options.session_track_state_sent == false) { + mybe->server_myds->myconn->options.session_track_state_sent = true; + set_previous_status_mode3(); + NEXT_IMMEDIATE_NEW(SETTING_SESSION_TRACK_STATE); + } + + return false; +} bool MySQL_Session::handler_again___verify_multiple_variables(MySQL_Connection* myconn) { for (auto i = 0; i < SQL_NAME_LAST_LOW_WM; i++) { @@ -2757,6 +2788,20 @@ bool MySQL_Session::handler_again___status_SETTING_SESSION_TRACK_GTIDS(int *_rc) return ret; } +bool MySQL_Session::handler_again___status_SETTING_SESSION_TRACK_VARIABLES(int *_rc) { + bool ret=false; + assert(mybe->server_myds->myconn); + ret = handler_again___status_SETTING_GENERIC_VARIABLE(_rc, (char *)"session_track_system_variables", "*", false); + return ret; +} + +bool MySQL_Session::handler_again___status_SETTING_SESSION_TRACK_STATE(int *_rc) { + bool ret=false; + assert(mybe->server_myds->myconn); + ret = handler_again___status_SETTING_GENERIC_VARIABLE(_rc, (char *)"session_track_state_change", "ON", false); + return ret; +} + bool MySQL_Session::handler_again___status_CHANGING_SCHEMA(int *_rc) { bool ret=false; //fprintf(stderr,"CHANGING_SCHEMA\n"); @@ -2904,6 +2949,11 @@ bool MySQL_Session::handler_again___status_CONNECTING_SERVER(int *_rc) { } enum session_status st=status; if (mybe->server_myds->myconn->async_state_machine==ASYNC_IDLE) { + if (handle_session_track_capabilities() == false) { + pause_until = thread->curtime + mysql_thread___connect_retries_delay*1000; + return false; + } + st=previous_status.top(); previous_status.pop(); NEXT_IMMEDIATE_NEW(st); @@ -2933,6 +2983,12 @@ bool MySQL_Session::handler_again___status_CONNECTING_SERVER(int *_rc) { previous_status.pop(); myds->wait_until=0; + if (handle_session_track_capabilities() == false) { + pause_until = thread->curtime + mysql_thread___connect_retries_delay*1000; + set_status(CONNECTING_SERVER); + return false; + } + // NOTE: Even if a connection has correctly been created, since the CLIENT_DEPRECATE_EOF // capability isn't always enforced to match for backend conns (no direct propagation), a // mismatch can take place after the creation. Right now this is only true for @@ -4898,6 +4954,41 @@ void MySQL_Session::handler_rc0_Process_GTID(MySQL_Connection *myconn) { } } +void MySQL_Session::handler_rc0_Process_Variables(MySQL_Connection *myconn) { + std::unordered_map var_map; + + if(myconn->get_variables(var_map)) { + std::string variable; + std::string value; + + for (int idx = 0 ; idx < SQL_NAME_LAST_HIGH_WM ; idx++) { + variable = mysql_tracked_variables[idx].set_variable_name; + + auto itr = var_map.find(variable); + if(itr != var_map.end()) { + value = itr->second; + proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 7, "Session=%p, backend=%p. Notification for session_track_system_variables: variable=%s, value=%s\n", this, this->mybe, variable.c_str(), value.c_str()); + + const MARIADB_CHARSET_INFO *ci = NULL; + if (variable == "character_set_results" || variable == "character_set_connection" || + variable == "character_set_client" || variable == "character_set_database") { + ci = proxysql_find_charset_name(value.c_str()); + } + else if (variable == "collation_connection") { + ci = proxysql_find_charset_collate(value.c_str()); + } + + if (ci) { + value = std::to_string(ci->nr); + } + + mysql_variables.client_set_value(this, idx, value); + mysql_variables.server_set_value(this, idx, value.c_str()); + } + } + } +} + void MySQL_Session::handler_KillConnectionIfNeeded() { if ( // two conditions // If the server connection is in a non-idle state (ASYNC_IDLE), and the current time is greater than or equal to mybe->server_myds->wait_until @@ -5095,6 +5186,10 @@ int MySQL_Session::handler() { goto handler_again; } + if (handler_again___verify_backend_session_track_variables()) { + goto handler_again; + } + // Optimize network traffic when we can use 'SET NAMES' if (verify_set_names(this)) { goto handler_again; @@ -5175,6 +5270,8 @@ int MySQL_Session::handler() { handler_rc0_Process_GTID(myconn); + handler_rc0_Process_Variables(myconn); + // if we are locked on hostgroup, the value of autocommit is copied from the backend connection // see bug #3549 if (locked_on_hostgroup >= 0) { @@ -5471,6 +5568,12 @@ bool MySQL_Session::handler_again___multiple_statuses(int *rc) { case SETTING_SESSION_TRACK_GTIDS: ret = handler_again___status_SETTING_SESSION_TRACK_GTIDS(rc); break; + case SETTING_SESSION_TRACK_VARIABLES: + ret = handler_again___status_SETTING_SESSION_TRACK_VARIABLES(rc); + break; + case SETTING_SESSION_TRACK_STATE: + ret = handler_again___status_SETTING_SESSION_TRACK_STATE(rc); + break; case SETTING_SET_NAMES: ret = handler_again___status_CHANGING_CHARSET(rc); break; @@ -8191,3 +8294,41 @@ char* MySQL_Session::get_current_query(int max_length) { return res; } + +/** + * @brief Handle session track capabilities validation. + * + * This function validates whether the backend connection has capabilities such as 'CLIENT_DEPRECATE_EOF' + * and 'CLIENT_SESSION_TRACKING' which are required to enable 'session_track_system_variables' in a MySQL session. + * + * If the connection lacks the capabilities and ProxySQL configuration is set in 'ENFORCED' mode, it returns the + * connection to the pool and set a backoff time for the backend server. This backoff time prevents the server from + * being selected again during connection pooling. + * + * @return 'true' if backend connection has required capabilities, otherwise returns 'false'. + */ +bool MySQL_Session::handle_session_track_capabilities() { + if (mysql_thread___session_track_variables != session_track_variables::ENFORCED) { + return true; + } + + // this function should not be called in these states + if (mybe == NULL + || mybe->server_myds == NULL + || mybe->server_myds->myconn == NULL + || mybe->server_myds->myconn->mysql == NULL) { + return true; + } + + MySQL_Connection *be_conn = mybe->server_myds->myconn; + unsigned long srv_cap = be_conn->mysql->server_capabilities; + + if ((srv_cap & CLIENT_DEPRECATE_EOF) == 0 || (srv_cap & CLIENT_SESSION_TRACKING) == 0) { + // be_conn->parent->server_backoff_time = thread->curtime + (600 * 1000000); // 10 minutes + be_conn->parent->server_backoff_time = thread->curtime + (30 * 1000000); // 30 seconds + mybe->server_myds->return_MySQL_Connection_To_Pool(); + return false; + } + + return true; +} diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index e299d3dab8..63e26b8df0 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -512,6 +512,7 @@ static char * mysql_thread_variables_names[]= { (char *)"protocol_compression_level", (char *)"ignore_min_gtid_annotations", (char *)"fast_forward_grace_close_ms", + (char *)"session_track_variables", NULL }; @@ -1156,6 +1157,8 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() { variables.data_packets_history_size=0; variables.protocol_compression_level=3; variables.ignore_min_gtid_annotations=false; + variables.session_track_variables=session_track_variables::DISABLED; + // status variables status_variables.mirror_sessions_current=0; __global_MySQL_Thread_Variables_version=1; @@ -2336,7 +2339,7 @@ char ** MySQL_Threads_Handler::get_variables_list() { VariablesPointers_int["eventslog_format"] = make_tuple(&variables.eventslog_format, 0, 0, true); VariablesPointers_int["wait_timeout"] = make_tuple(&variables.wait_timeout, 0, 0, true); VariablesPointers_int["data_packets_history_size"] = make_tuple(&variables.data_packets_history_size, 0, 0, true); - + VariablesPointers_int["session_track_variables"] = make_tuple(&variables.session_track_variables, 0, 2, false); } @@ -4310,6 +4313,7 @@ void MySQL_Thread::refresh_variables() { REFRESH_VARIABLE_INT(handle_warnings); REFRESH_VARIABLE_INT(evaluate_replication_lag_on_servers_load); REFRESH_VARIABLE_BOOL(ignore_min_gtid_annotations); + REFRESH_VARIABLE_INT(session_track_variables); #ifdef DEBUG REFRESH_VARIABLE_BOOL(session_debug); #endif /* DEBUG */ @@ -5607,7 +5611,11 @@ MySQL_Connection * MySQL_Thread::get_MyConn_local(unsigned int _hid, MySQL_Sessi std::vector parents; // this is a vector of srvers that needs to be excluded in case gtid_uuid is used MySQL_Connection *c=NULL; for (i=0; ilen; i++) { - c=(MySQL_Connection *)cached_connections->index(i); + c = (MySQL_Connection *) cached_connections->index(i); + // skip servers that are in backoff period + if (c->parent->server_backoff_time > curtime) + continue; + if (c->parent->myhgc->hid==_hid && sess->client_myds->myconn->match_tracked_options(c)) { // options are all identical if ( (gtid_uuid == NULL) || // gtid_uuid is not used diff --git a/lib/MySrvC.cpp b/lib/MySrvC.cpp index 860ae56efe..1e94b41aac 100644 --- a/lib/MySrvC.cpp +++ b/lib/MySrvC.cpp @@ -31,6 +31,7 @@ MySrvC::MySrvC( bytes_recv=0; max_connections_used=0; queries_gtid_sync=0; + server_backoff_time = 0; time_last_detected_error=0; connect_ERR_at_time_last_detected_error=0; shunned_automatic=false; diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 0e5367edfc..346d394566 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -452,6 +452,8 @@ MySQL_Connection::MySQL_Connection() { options.init_connect_sent=false; options.session_track_gtids = NULL; options.session_track_gtids_sent = false; + options.session_track_variables_sent = false; + options.session_track_state_sent = false; options.ldap_user_variable=NULL; options.ldap_user_variable_value=NULL; options.ldap_user_variable_sent=false; @@ -866,13 +868,18 @@ void MySQL_Connection::connect_start_SetClientFlag(unsigned long& client_flags) } } - // set 'CLIENT_DEPRECATE_EOF' flag if explicitly stated by 'mysql-enable_server_deprecate_eof'. - // Capability is disabled by default in 'mariadb_client', so setting this option is not optional - // for having 'CLIENT_DEPRECATE_EOF' in the connection to be stablished. + // 'CLIENT_DEPRECATE_EOF' capability is disabled by default in mariadb_client. + // Based on the value of 'mysql-enable_server_deprecate_eof', enable this + // capability in a new connection. if (mysql_thread___enable_server_deprecate_eof) { mysql->options.client_flag |= CLIENT_DEPRECATE_EOF; } + // override 'mysql-enable_server_deprecate_eof' behavior if 'session_track_variables' is set to 'ENFORCED' + if (mysql_thread___session_track_variables == session_track_variables::ENFORCED) { + mysql->options.client_flag |= CLIENT_DEPRECATE_EOF; + } + if (myds != NULL) { if (myds->sess != NULL) { if (myds->sess->session_fast_forward) { // this is a fast_forward connection @@ -3082,6 +3089,8 @@ void MySQL_Connection::reset() { options.session_track_gtids = NULL; options.session_track_gtids_sent = false; } + options.session_track_variables_sent = false; + options.session_track_state_sent = false; } bool MySQL_Connection::get_gtid(char *buff, uint64_t *trx_id) { @@ -3116,6 +3125,46 @@ bool MySQL_Connection::get_gtid(char *buff, uint64_t *trx_id) { return ret; } +bool MySQL_Connection::get_variables(std::unordered_map& variables) { + bool ret = false; + + if ((mysql != nullptr) + && (mysql->net.last_errno == 0) + && (mysql->server_status & SERVER_SESSION_STATE_CHANGED)) { + // when there is no error and status changed + const char *data; + size_t length; + + if (mysql_session_track_get_first(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &length) == 0) { + string var_name(data, length); + string val; + + // get_first() returns a variable_name + // get_next() will return the value + bool expect_value = true; + + while (mysql_session_track_get_next(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &length) == 0) { + if (expect_value) { + val = string(data, length); + variables[var_name] = val; + // got a value in this iteration + // in the next iteration, we have to expect a variable_name + expect_value = false; + } else { + var_name = string(data, length); + // got a variable_name in this iteration + // in the next iteration, we have to expect the value of this variable + expect_value = true; + } + } + + ret = true; + } + } + + return ret; +} + void MySQL_Connection::set_ssl_params(MYSQL *mysql, MySQLServers_SslParams *ssl_params) { if (ssl_params == NULL) { mysql_ssl_set(mysql, diff --git a/test/tap/groups/groups.json b/test/tap/groups/groups.json index f5223ba2ba..2ec51203d8 100644 --- a/test/tap/groups/groups.json +++ b/test/tap/groups/groups.json @@ -233,5 +233,6 @@ "test_ssl_fast_forward-2_libmysql-t": [ "default-g4", "mysql-auto_increment_delay_multiplex=0-g4", "mysql-multiplexing=false-g4", "mysql-query_digests=0-g4", "mysql-query_digests_keep_comment=1-g4" ], "test_ssl_fast_forward-3_libmariadb-t": [ "default-g4", "mysql-auto_increment_delay_multiplex=0-g4", "mysql-multiplexing=false-g4", "mysql-query_digests=0-g4", "mysql-query_digests_keep_comment=1-g4" ], "test_ssl_fast_forward-3_libmysql-t": [ "default-g4", "mysql-auto_increment_delay_multiplex=0-g4", "mysql-multiplexing=false-g4", "mysql-query_digests=0-g4", "mysql-query_digests_keep_comment=1-g4" ], - "test_ignore_min_gtid-t": [ "default-g4", "mysql-auto_increment_delay_multiplex=0-g4", "mysql-multiplexing=false-g4", "mysql-query_digests=0-g4", "mysql-query_digests_keep_comment=1-g4" ] + "test_ignore_min_gtid-t": [ "default-g4", "mysql-auto_increment_delay_multiplex=0-g4", "mysql-multiplexing=false-g4", "mysql-query_digests=0-g4", "mysql-query_digests_keep_comment=1-g4" ], + "mysql-track_system_variables-t" : [ "default-g4","mysql-auto_increment_delay_multiplex=0-g4","mysql-multiplexing=false-g4","mysql-query_digests=0-g4","mysql-query_digests_keep_comment=1-g4" ] } diff --git a/test/tap/tests/mysql-track_system_variables-t.cpp b/test/tap/tests/mysql-track_system_variables-t.cpp new file mode 100644 index 0000000000..592ade59d4 --- /dev/null +++ b/test/tap/tests/mysql-track_system_variables-t.cpp @@ -0,0 +1,101 @@ +/** + * @file test_track_system_variables-t.cpp + * @brief This test verifies that ProxySQL properly tracks session-specific + * system variables across the backend connections. + */ + +#include +#include +#include "json.hpp" +#include "mysql.h" +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +using nlohmann::json; + +int main(int argc, char** argv) { + CommandLine cl; + if (cl.getEnv()) { + diag("Failed to get the required environmental variables."); + return exit_status(); + } + + plan(1); + + MYSQL* admin = init_mysql_conn(cl.admin_host, cl.admin_port, cl.admin_username, cl.admin_password); + if (!admin) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(admin)); + return exit_status(); + } + + MYSQL_QUERY_T(admin, "SET mysql-session_track_variables=1"); + MYSQL_QUERY_T(admin, "LOAD MYSQL VARIABLES TO RUNTIME"); + + MYSQL* proxy = init_mysql_conn(cl.host, cl.port, cl.username, cl.password, true); + if (!proxy) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxy)); + return exit_status(); + } + + MYSQL_QUERY_T(proxy, "CREATE DATABASE IF NOT EXISTS test"); + MYSQL_QUERY_T(proxy, "SELECT 1"); + MYSQL_RES* reset_result = mysql_store_result(proxy); + mysql_free_result(reset_result); + + MYSQL_QUERY_T(proxy, "DROP PROCEDURE IF EXISTS test.set_innodb_lock_wait_timeout"); + const char* create_proc = + "CREATE PROCEDURE test.set_innodb_lock_wait_timeout() " + "BEGIN " + " SET innodb_lock_wait_timeout = CAST(FLOOR(50 + (RAND() * 100)) AS UNSIGNED); " + "END"; + + MYSQL_QUERY_T(proxy, create_proc); + MYSQL_QUERY_T(proxy, "CALL test.set_innodb_lock_wait_timeout()"); + + int set_value = -1; + MYSQL_QUERY_T(proxy, "SELECT @@innodb_lock_wait_timeout"); + MYSQL_RES* result = mysql_store_result(proxy); + if (result) { + MYSQL_ROW row = mysql_fetch_row(result); + if (row) { + set_value = atoi(row[0]); + } + mysql_free_result(result); + } + + MYSQL_QUERY(proxy, "PROXYSQL INTERNAL SESSION"); + result = mysql_store_result(proxy); + MYSQL_ROW row = mysql_fetch_row(result); + auto j_session = nlohmann::json::parse(row[0]); + mysql_free_result(result); + + int backend_value = -1; + int client_value = -1; + if (j_session.contains("backends")) { + for (auto& backend : j_session["backends"]) { + if (backend != nullptr && backend.contains("conn")) { + if (backend["conn"].contains("innodb_lock_wait_timeout")) { + backend_value = std::stoi(backend["conn"]["innodb_lock_wait_timeout"].get()); + break; + } + } + } + } + if (j_session.contains("conn")) { + if (j_session["conn"].contains("innodb_lock_wait_timeout")) { + client_value = std::stoi(j_session["conn"]["innodb_lock_wait_timeout"].get()); + } + } + + ok(set_value == backend_value && set_value == client_value, + "Match session innodb_lock_wait_timeout value with backend & client variable list. Expected: %d, Backend: %d, Client: %d", set_value, backend_value, client_value); + + // cleanup + MYSQL_QUERY_T(admin, "SET mysql-session_track_variables=0"); + MYSQL_QUERY_T(admin, "LOAD MYSQL VARIABLES TO RUNTIME"); + + mysql_close(proxy); + mysql_close(admin); + return exit_status(); +} diff --git a/test/tap/tests/reg_test_4264-commit_rollback-t.cpp b/test/tap/tests/reg_test_4264-commit_rollback-t.cpp index 1c5c6585ab..11533dc1d3 100644 --- a/test/tap/tests/reg_test_4264-commit_rollback-t.cpp +++ b/test/tap/tests/reg_test_4264-commit_rollback-t.cpp @@ -1129,6 +1129,9 @@ int prepare_tables_and_config(MYSQL* admin, MYSQL* proxy) { MYSQL_QUERY_T(admin, "LOAD MYSQL SERVERS TO RUNTIME"); MYSQL_QUERY_T(admin, "SET mysql-auto_increment_delay_multiplex=0"); + MYSQL_QUERY_T(admin, "SET mysql-default_session_track_gtids='OFF'"); + MYSQL_QUERY_T(admin, "SET mysql-session_track_variables=0"); + MYSQL_QUERY_T(admin, "LOAD MYSQL VARIABLES TO RUNTIME"); MYSQL_QUERY_T(admin, "LOAD MYSQL QUERY RULES FROM DISK"); diff --git a/test/tap/tests/test_binlog_reader-t.cpp b/test/tap/tests/test_binlog_reader-t.cpp index f4cfaca5d8..17d4b5499b 100644 --- a/test/tap/tests/test_binlog_reader-t.cpp +++ b/test/tap/tests/test_binlog_reader-t.cpp @@ -259,6 +259,9 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } + MYSQL_QUERY_T(proxysql_admin, "SET mysql-session_track_variables=0"); + MYSQL_QUERY_T(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); + vector> failed_rows {}; vector reader_1_read {}; vector reader_2_read {}; @@ -279,10 +282,6 @@ int main(int argc, char** argv) { rc = perform_update(proxysql_mysql, NUM_ROWS); if (rc != EXIT_SUCCESS) { goto cleanup; } - MYSQL_RES* my_res = mysql_store_result(proxysql_admin); - vector pre_select_rows = extract_mysql_rows(my_res); - mysql_free_result(my_res); - int r_row = rand() % NUM_ROWS; if (r_row == 0) { r_row = 1; }