diff --git a/include/MySQL_Monitor.hpp b/include/MySQL_Monitor.hpp index 8a8883bab1..1d8cfb5565 100644 --- a/include/MySQL_Monitor.hpp +++ b/include/MySQL_Monitor.hpp @@ -51,6 +51,7 @@ struct cmp_str { #define AWS_Aurora_Nentries 50 #define N_L_ASE 16 + /* Implementation of monitoring in AWS Aurora will be different than previous modules diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index c51351bc20..3a9762bdf9 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -383,6 +383,32 @@ enum handle_unknown_charset { HANDLE_UNKNOWN_CHARSET__MAX_HANDLE_VALUE }; +/** + * Enum holding the different MySQL connection errors that are used to report + * invalid states in the backend connections. + */ +enum PROXYSQL_MYSQL_ERR { + ER_PROXYSQL_MAX_CONN_TIMEOUT = 9001, + ER_PROXYSQL_MAX_CONN_FAILURES = 9002, + ER_PROXYSQL_COMMAND_NOT_SUPPORTED = 9003, + ER_PROXYSQL_OFFLINE_SRV = 9004, + ER_PROXYSQL_LAGGING_SRV = 9005, + ER_PROXYSQL_PING_TIMEOUT = 9006, + ER_PROXYSQL_CHANGE_USER_TIMEOUT = 9007, + ER_PROXYSQL_GR_HEALTH_CHECK_TIMEOUT = 9008, + ER_PROXYSQL_GR_HEALTH_CHECKS_MISSED = 9009, + ER_PROXYSQL_READ_ONLY_CHECK_CONN_TIMEOUT = 9010, + ER_PROXYSQL_READ_ONLY_CHECK_TIMEOUT = 9011, + ER_PROXYSQL_READ_ONLY_CHECKS_MISSED = 9012, + ER_PROXYSQL_GALERA_HEALTH_CHECK_CONN_TIMEOUT = 9013, + ER_PROXYSQL_GALERA_HEALTH_CHECK_TIMEOUT = 9014, + ER_PROXYSQL_GALERA_HEALTH_CHECKS_MISSED = 9015, + ER_PROXYSQL_AWS_NO_PINGABLE_SRV = 9016, + ER_PROXYSQL_AWS_HEALTH_CHECK_CONN_TIMEOUT = 9017, + ER_PROXYSQL_AWS_HEALTH_CHECK_TIMEOUT = 9018, + ER_PROXYSQL_SRV_NULL_REPLICATION_LAG = 9019, +}; + #endif /* PROXYSQL_ENUMS */ diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 00a3515532..3ae7e07747 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "MySQL_Protocol.h" #include "MySQL_HostGroups_Manager.h" #include "MySQL_Monitor.hpp" #include "proxysql.h" @@ -877,6 +878,7 @@ void * monitor_connect_thread(void *arg) { { proxy_error("Server %s:%d is returning \"Your password has expired.\" for monitoring user\n", mmsd->hostname, mmsd->port); } + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); } else { connect_success = true; } @@ -992,6 +994,7 @@ void * monitor_ping_thread(void *arg) { #else proxy_error("Error after %dms on server %s:%d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd->hostname, mmsd->port, mmsd->mysql_error_msg); #endif // DEBUG + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); mysql_close(mmsd->mysql); // if we reached here we should destroy it mmsd->mysql=NULL; } else { @@ -1006,12 +1009,14 @@ void * monitor_ping_thread(void *arg) { #else proxy_error("Error on server %s:%d : %s\n", mmsd->hostname, mmsd->port, mmsd->mysql_error_msg); #endif // DEBUG + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // set_wait_timeout failed } mmsd->mysql=NULL; } else { // really not sure how we reached here, drop it proxy_error("Error after %dms: mmsd %p , MYSQL %p , FD %d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; @@ -1138,6 +1143,7 @@ void * monitor_read_only_thread(void *arg) { free(mmsd->mysql_error_msg); mmsd->mysql_error_msg = new_error; proxy_error("Timeout on read_only check for %s:%d after %lldms. Unable to create a connection. If the server is overload, increase mysql-monitor_connect_timeout. Error: %s.\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000, new_error); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_READ_ONLY_CHECK_CONN_TIMEOUT); timeout_reached = true; goto __exit_monitor_read_only_thread; //goto __fast_exit_monitor_read_only_thread; @@ -1163,6 +1169,7 @@ void * monitor_read_only_thread(void *arg) { if (now > mmsd->t1 + mysql_thread___monitor_read_only_timeout * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on read_only check for %s:%d after %lldms. If the server is overload, increase mysql-monitor_read_only_timeout.\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_READ_ONLY_CHECK_TIMEOUT); timeout_reached = true; goto __exit_monitor_read_only_thread; } @@ -1192,6 +1199,7 @@ void * monitor_read_only_thread(void *arg) { if (now > mmsd->t1 + mysql_thread___monitor_read_only_timeout * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on read_only check for %s:%d after %lldms. If the server is overload, increase mysql-monitor_read_only_timeout.\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_READ_ONLY_CHECK_TIMEOUT); timeout_reached = true; goto __exit_monitor_read_only_thread; } @@ -1297,6 +1305,7 @@ VALGRIND_ENABLE_ERROR_REPORTING; if (resultset->rows_count) { // disable host proxy_error("Server %s:%d missed %d read_only checks. Assuming read_only=1\n", mmsd->hostname, mmsd->port, max_failures); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_READ_ONLY_CHECKS_MISSED); MyHGM->read_only_action(mmsd->hostname, mmsd->port, read_only); // N timeouts reached } delete resultset; @@ -1311,6 +1320,7 @@ VALGRIND_ENABLE_ERROR_REPORTING; if (mmsd->interr || mmsd->mysql_error_msg) { // check failed if (mmsd->mysql) { proxy_error("Got error: mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; @@ -1328,6 +1338,7 @@ VALGRIND_ENABLE_ERROR_REPORTING; // if we reached here we didn't put the connection back if (mmsd->mysql_error_msg) { proxy_error("Got error: mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // if we reached here we should destroy it mmsd->mysql=NULL; @@ -1338,12 +1349,14 @@ VALGRIND_ENABLE_ERROR_REPORTING; GloMyMon->My_Conn_Pool->put_connection(mmsd->hostname,mmsd->port,mmsd->mysql); } else { proxy_error("Got error: mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // set_wait_timeout failed } mmsd->mysql=NULL; } else { // really not sure how we reached here, drop it proxy_error("Got error: mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; @@ -1401,6 +1414,7 @@ void * monitor_group_replication_thread(void *arg) { if (now > mmsd->t1 + mysql_thread___monitor_groupreplication_healthcheck_timeout * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on group replication health check for %s:%d after %lldms. If the server is overload, increase mysql-monitor_groupreplication_healthcheck_timeout. Assuming viable_candidate=nO and read_only=YES\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_GR_HEALTH_CHECK_TIMEOUT); goto __exit_monitor_group_replication_thread; } if (mmsd->interr) { @@ -1430,6 +1444,7 @@ void * monitor_group_replication_thread(void *arg) { if (now > mmsd->t1 + mysql_thread___monitor_groupreplication_healthcheck_timeout * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on group replication health check for %s:%d after %lldms. If the server is overload, increase mysql-monitor_groupreplication_healthcheck_timeout. Assuming viable_candidate=nO and read_only=YES\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_GR_HEALTH_CHECK_TIMEOUT); goto __exit_monitor_group_replication_thread; } if (GloMyMon->shutdown==true) { @@ -1544,6 +1559,7 @@ void * monitor_group_replication_thread(void *arg) { if (num_timeouts == mysql_thread___monitor_groupreplication_healthcheck_max_timeout_count) { proxy_error("Server %s:%d missed %d group replication checks. Number retries %d, Assuming offline\n", mmsd->hostname, mmsd->port, num_timeouts, num_timeouts); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_GR_HEALTH_CHECKS_MISSED); MyHGM->update_group_replication_set_offline(mmsd->hostname, mmsd->port, mmsd->writer_hostgroup, mmsd->mysql_error_msg); } else { // not enough timeout @@ -1634,6 +1650,7 @@ void * monitor_group_replication_thread(void *arg) { if (mmsd->interr || mmsd->mysql_error_msg) { // check failed if (mmsd->mysql) { proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; @@ -1651,6 +1668,7 @@ void * monitor_group_replication_thread(void *arg) { // if we reached here we didn't put the connection back if (mmsd->mysql_error_msg) { proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // if we reached here we should destroy it mmsd->mysql=NULL; @@ -1661,12 +1679,14 @@ void * monitor_group_replication_thread(void *arg) { GloMyMon->My_Conn_Pool->put_connection(mmsd->hostname,mmsd->port,mmsd->mysql); } else { proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // set_wait_timeout failed } mmsd->mysql=NULL; } else { // really not sure how we reached here, drop it proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; @@ -1710,6 +1730,7 @@ void * monitor_galera_thread(void *arg) { free(mmsd->mysql_error_msg); mmsd->mysql_error_msg = new_error; proxy_error("Error on Galera check for %s:%d after %lldms. Unable to create a connection. If the server is overload, increase mysql-monitor_connect_timeout. Error: %s.\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000, new_error); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_GALERA_HEALTH_CHECK_CONN_TIMEOUT); goto __exit_monitor_galera_thread; } } @@ -1752,6 +1773,7 @@ void * monitor_galera_thread(void *arg) { if (now > mmsd->t1 + mysql_thread___monitor_galera_healthcheck_timeout * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on Galera health check for %s:%d after %lldms. If the server is overload, increase mysql-monitor_galera_healthcheck_timeout.\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_GALERA_HEALTH_CHECK_TIMEOUT); goto __exit_monitor_galera_thread; } if (GloMyMon->shutdown==true) { @@ -1768,6 +1790,7 @@ void * monitor_galera_thread(void *arg) { if (now > mmsd->t1 + mysql_thread___monitor_galera_healthcheck_timeout * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on Galera health check for %s:%d after %lldms. If the server is overload, increase mysql-monitor_galera_healthcheck_timeout.\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_GALERA_HEALTH_CHECK_TIMEOUT); goto __exit_monitor_galera_thread; } if (GloMyMon->shutdown==true) { @@ -1958,6 +1981,7 @@ void * monitor_galera_thread(void *arg) { // it was a timeout. Check if we are having consecutive timeout if (num_timeouts == mysql_thread___monitor_galera_healthcheck_max_timeout_count) { proxy_error("Server %s:%d missed %d Galera checks. Assuming offline\n", mmsd->hostname, mmsd->port, num_timeouts); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_GALERA_HEALTH_CHECKS_MISSED); MyHGM->update_galera_set_offline(mmsd->hostname, mmsd->port, mmsd->writer_hostgroup, mmsd->mysql_error_msg); } else { // not enough timeout @@ -2018,6 +2042,7 @@ void * monitor_galera_thread(void *arg) { if (mmsd->interr || mmsd->mysql_error_msg) { // check failed if (mmsd->mysql) { proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; @@ -2035,6 +2060,7 @@ void * monitor_galera_thread(void *arg) { // if we reached here we didn't put the connection back if (mmsd->mysql_error_msg) { proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // if we reached here we should destroy it mmsd->mysql=NULL; @@ -2045,12 +2071,14 @@ void * monitor_galera_thread(void *arg) { GloMyMon->My_Conn_Pool->put_connection(mmsd->hostname,mmsd->port,mmsd->mysql); } else { proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // set_wait_timeout failed } mmsd->mysql=NULL; } else { // really not sure how we reached here, drop it proxy_error("Got error. mmsd %p , MYSQL %p , FD %d : %s\n", mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; @@ -2222,6 +2250,7 @@ void * monitor_replication_lag_thread(void *arg) { repl_lag=atoi(row[j]); } else { proxy_error("Replication lag on server %s:%d is NULL, using the value %d (mysql-monitor_slave_lag_when_null)\n", mmsd->hostname, mmsd->port, mysql_thread___monitor_slave_lag_when_null); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_SRV_NULL_REPLICATION_LAG); } } } @@ -2258,6 +2287,7 @@ void * monitor_replication_lag_thread(void *arg) { #else proxy_error("Error after %dms on server %s:%d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd->hostname, mmsd->port, mmsd->mysql_error_msg); #endif // DEBUG + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); mysql_close(mmsd->mysql); mmsd->mysql=NULL; } @@ -2279,6 +2309,7 @@ void * monitor_replication_lag_thread(void *arg) { #else proxy_error("Error after %dms on server %s:%d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd->hostname, mmsd->port, mmsd->mysql_error_msg); #endif // DEBUG + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); mysql_close(mmsd->mysql); // if we reached here we should destroy it mmsd->mysql=NULL; } else { @@ -2294,6 +2325,7 @@ void * monitor_replication_lag_thread(void *arg) { #else proxy_error("Error after %dms on server %s:%d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd->hostname, mmsd->port, mmsd->mysql_error_msg); #endif // DEBUG + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); mysql_close(mmsd->mysql); // set_wait_timeout failed } mmsd->mysql=NULL; @@ -2304,6 +2336,7 @@ void * monitor_replication_lag_thread(void *arg) { #else proxy_error("Error after %dms on server %s:%d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd->hostname, mmsd->port, mmsd->mysql_error_msg); #endif // DEBUG + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); mysql_close(mmsd->mysql); mmsd->mysql=NULL; } @@ -4215,6 +4248,7 @@ void * monitor_AWS_Aurora_thread_HG(void *arg) { if (found_pingable_host == false) { proxy_error("No node is pingable for AWS Aurora cluster with writer HG %u\n", wHG); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_AWS_NO_PINGABLE_SRV); next_loop_at = t1 + check_interval_ms * 1000; continue; } @@ -4253,6 +4287,7 @@ void * monitor_AWS_Aurora_thread_HG(void *arg) { free(mmsd->mysql_error_msg); mmsd->mysql_error_msg = new_error; proxy_error("Error on AWS Aurora check for %s:%d after %lldms. Unable to create a connection. %sError: %s.\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000, (access_denied ? "" : "If the server is overload, increase mysql-monitor_connect_timeout. " ) , new_error); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_AWS_HEALTH_CHECK_CONN_TIMEOUT); goto __exit_monitor_aws_aurora_HG_thread; } } @@ -4270,6 +4305,7 @@ void * monitor_AWS_Aurora_thread_HG(void *arg) { if (now > mmsd->t1 + mmsd->aws_aurora_check_timeout_ms * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on AWS Aurora health check for %s:%d after %lldms. If the server is overload, increase mysql_aws_aurora_hostgroups.check_timeout_ms\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_AWS_HEALTH_CHECK_TIMEOUT); goto __exit_monitor_aws_aurora_HG_thread; } if (GloMyMon->shutdown==true) { @@ -4286,6 +4322,7 @@ void * monitor_AWS_Aurora_thread_HG(void *arg) { if (now > mmsd->t1 + mmsd->aws_aurora_check_timeout_ms * 1000) { mmsd->mysql_error_msg=strdup("timeout check"); proxy_error("Timeout on AWS Aurora health check for %s:%d after %lldms. If the server is overload, increase mysql_aws_aurora_hostgroups.check_timeout_ms\n", mmsd->hostname, mmsd->port, (now-mmsd->t1)/1000); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, ER_PROXYSQL_AWS_HEALTH_CHECK_TIMEOUT); goto __exit_monitor_aws_aurora_HG_thread; } if (GloMyMon->shutdown==true) { @@ -4401,6 +4438,7 @@ void * monitor_AWS_Aurora_thread_HG(void *arg) { if (mmsd->mysql_error_msg) { #ifdef DEBUG proxy_error("Error after %dms: server %s:%d , mmsd %p , MYSQL %p , FD %d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd->hostname, mmsd->port, mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); #else proxy_error("Error after %dms on server %s:%d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd->hostname, mmsd->port, mmsd->mysql_error_msg); @@ -4414,12 +4452,14 @@ void * monitor_AWS_Aurora_thread_HG(void *arg) { GloMyMon->My_Conn_Pool->put_connection(mmsd->hostname,mmsd->port,mmsd->mysql); } else { proxy_error("Error after %dms: mmsd %p , MYSQL %p , FD %d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); // set_wait_timeout failed } mmsd->mysql=NULL; } else { // really not sure how we reached here, drop it proxy_error("Error after %dms: mmsd %p , MYSQL %p , FD %d : %s\n", (mmsd->t2-mmsd->t1)/1000, mmsd, mmsd->mysql, mmsd->mysql->net.fd, mmsd->mysql_error_msg); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, mmsd->hostgroup_id, mmsd->hostname, mmsd->port, mysql_errno(mmsd->mysql)); GloMyMon->My_Conn_Pool->conn_unregister(mmsd); mysql_close(mmsd->mysql); mmsd->mysql=NULL; diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index ffe65f51d2..593c454a3a 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -5,6 +5,7 @@ #include "re2/re2.h" #include "re2/regexp.h" #include "SpookyV2.h" +#include "mysqld_error.h" #include "set_parser.h" #include "MySQL_Data_Stream.h" @@ -169,7 +170,6 @@ void * kill_query_thread(void *arg) { } if (!ret) { proxy_error("Failed to connect to server %s:%d to run KILL %s %llu: Error: %s\n" , ka->hostname, ka->port, ( ka->kill_type==KILL_QUERY ? "QUERY" : "CONNECTION" ) , ka->id, mysql_error(mysql)); - // TODO: Ask for this specific case: 'modify killargs to include hostgroup info MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, ka->hid, ka->hostname, ka->port, mysql_errno(mysql)); goto __exit_kill_query_thread; } @@ -1441,16 +1441,17 @@ int MySQL_Session::handler_again___status_PINGING_SERVER() { set_status(session_status___NONE); return -1; } else { - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, mysql_errno(myconn->mysql)); if (rc==-1 || rc==-2) { if (rc==-2) { unsigned long long us = mysql_thread___ping_timeout_server*1000; us += thread->curtime; us -= myds->wait_until; proxy_error("Ping timeout during ping on %s:%d after %lluus (timeout %dms)\n", myconn->parent->address, myconn->parent->port, us, mysql_thread___ping_timeout_server); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, ER_PROXYSQL_PING_TIMEOUT); } else { // rc==-1 int myerr=mysql_errno(myconn->mysql); proxy_error("Detected a broken connection during ping on (%d,%s,%d) , FD (Conn:%d , MyDS:%d) : %d, %s\n", myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myds->fd, myds->myconn->fd, myerr, mysql_error(myconn->mysql)); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myerr); } myds->destroy_MySQL_Connection_From_Pool(false); myds->fd=0; @@ -1495,15 +1496,19 @@ int MySQL_Session::handler_again___status_RESETTING_CONNECTION() { set_status(session_status___NONE); return -1; } else { - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, mysql_errno(myconn->mysql)); if (rc==-1 || rc==-2) { if (rc==-2) { proxy_error("Change user timeout during COM_CHANGE_USER on %s , %d\n", myconn->parent->address, myconn->parent->port); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, ER_PROXYSQL_CHANGE_USER_TIMEOUT); } else { // rc==-1 int myerr=mysql_errno(myconn->mysql); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr != 0) { proxy_error("Detected an error during COM_CHANGE_USER on (%d,%s,%d) , FD (Conn:%d , MyDS:%d) : %d, %s\n", myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myds->fd, myds->myconn->fd, myerr, mysql_error(myconn->mysql)); } else { @@ -1514,7 +1519,7 @@ int MySQL_Session::handler_again___status_RESETTING_CONNECTION() { myconn->parent->port, myds->fd, myds->myconn->fd, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -1922,10 +1927,13 @@ bool MySQL_Session::handler_again___status_SETTING_INIT_CONNECT(int *_rc) { if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, mysql_errno(myconn->mysql)); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -1937,7 +1945,7 @@ bool MySQL_Session::handler_again___status_SETTING_INIT_CONNECT(int *_rc) { myconn->parent->address, myconn->parent->port, current_hostgroup, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2027,10 +2035,13 @@ bool MySQL_Session::handler_again___status_SETTING_LDAP_USER_VARIABLE(int *_rc) if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myerr); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -2042,7 +2053,7 @@ bool MySQL_Session::handler_again___status_SETTING_LDAP_USER_VARIABLE(int *_rc) myconn->parent->address, myconn->parent->port, current_hostgroup, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2118,10 +2129,13 @@ bool MySQL_Session::handler_again___status_SETTING_SQL_LOG_BIN(int *_rc) { if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myerr); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -2133,7 +2147,7 @@ bool MySQL_Session::handler_again___status_SETTING_SQL_LOG_BIN(int *_rc) { myconn->parent->address, myconn->parent->port, current_hostgroup, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2197,10 +2211,13 @@ bool MySQL_Session::handler_again___status_CHANGING_CHARSET(int *_rc) { if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myerr); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { if (myerr == 2019) { proxy_error("Client trying to set a charset/collation (%u) not supported by backend (%s:%d). Changing it to %u\n", charset, myconn->parent->address, myconn->parent->port, mysql_tracked_variables[SQL_CHARACTER_SET].default_value); @@ -2214,7 +2231,7 @@ bool MySQL_Session::handler_again___status_CHANGING_CHARSET(int *_rc) { "Detected a broken connection during SET NAMES on %s , %d : %d, %s\n", myconn->parent->address, myconn->parent->port, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2314,10 +2331,13 @@ bool MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE(int *_rc, co if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myerr); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -2330,7 +2350,7 @@ bool MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE(int *_rc, co myconn->parent->address, myconn->parent->port, current_hostgroup, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2433,9 +2453,13 @@ bool MySQL_Session::handler_again___status_SETTING_MULTI_STMT(int *_rc) { if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -2446,7 +2470,7 @@ bool MySQL_Session::handler_again___status_SETTING_MULTI_STMT(int *_rc) { "Detected a broken connection during setting MYSQL_OPTION_MULTI_STATEMENTS on %s , %d : %d, %s\n", myconn->parent->address, myconn->parent->port, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2511,10 +2535,13 @@ bool MySQL_Session::handler_again___status_CHANGING_SCHEMA(int *_rc) { if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myerr); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -2525,7 +2552,7 @@ bool MySQL_Session::handler_again___status_CHANGING_SCHEMA(int *_rc) { "Detected a broken connection during INIT_DB on %s , %d : %d, %s\n", myconn->parent->address, myconn->parent->port, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2745,13 +2772,16 @@ bool MySQL_Session::handler_again___status_CHANGING_USER_SERVER(int *_rc) { previous_status.pop(); NEXT_IMMEDIATE_NEW(st); } else { - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, mysql_errno(myconn->mysql)); if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -2762,7 +2792,7 @@ bool MySQL_Session::handler_again___status_CHANGING_USER_SERVER(int *_rc) { "Detected a broken connection during change user on %s, %d : %d, %s\n", myconn->parent->address, myconn->parent->port, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -2793,6 +2823,7 @@ bool MySQL_Session::handler_again___status_CHANGING_USER_SERVER(int *_rc) { if (rc==-2) { bool retry_conn=false; proxy_error("Change user timeout during COM_CHANGE_USER on %s , %d\n", myconn->parent->address, myconn->parent->port); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, ER_PROXYSQL_CHANGE_USER_TIMEOUT); if ((myds->myconn->reusable==true) && myds->myconn->IsActiveTransaction()==false && myds->myconn->MultiplexDisabled()==false) { retry_conn=true; } @@ -2851,13 +2882,16 @@ bool MySQL_Session::handler_again___status_CHANGING_AUTOCOMMIT(int *_rc) { myds->DSS = STATE_MARIADB_GENERIC; NEXT_IMMEDIATE_NEW(st); } else { - MyHGM->p_update_mysql_error_counter(p_mysql_error_type::mysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, mysql_errno(myconn->mysql)); if (rc==-1) { // the command failed int myerr=mysql_errno(myconn->mysql); - // if rc was '-1' but 'mysql_errno' is 0, it means that the connection - // wasn't stablished because the server was detected to be down, *prior* - // to the connection attempt, and the session should be destroyed. + MyHGM->p_update_mysql_error_counter( + p_mysql_error_type::mysql, + myconn->parent->myhgc->hid, + myconn->parent->address, + myconn->parent->port, + ( myerr ? myerr : ER_PROXYSQL_OFFLINE_SRV ) + ); if (myerr >= 2000 || myerr == 0) { bool retry_conn=false; // client error, serious @@ -2868,7 +2902,7 @@ bool MySQL_Session::handler_again___status_CHANGING_AUTOCOMMIT(int *_rc) { "Detected a broken connection during SET AUTOCOMMIT on %s , %d : %d, %s\n", myconn->parent->address, myconn->parent->port, - myerr, + ER_PROXYSQL_OFFLINE_SRV, "Detected offline server prior to statement execution" ); } @@ -3711,9 +3745,11 @@ int MySQL_Session::handler_ProcessingQueryError_CheckBackendConnectionStatus(MyS if (myconn->server_status==MYSQL_SERVER_STATUS_SHUNNED_REPLICATION_LAG) { thread->status_variables.stvar[st_var_backend_lagging_during_query]++; proxy_error("Detected a lagging server during query: %s, %d\n", myconn->parent->address, myconn->parent->port); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, ER_PROXYSQL_LAGGING_SRV); } else { thread->status_variables.stvar[st_var_backend_offline_during_query]++; proxy_error("Detected an offline server during query: %s, %d\n", myconn->parent->address, myconn->parent->port); + MyHGM->p_update_mysql_error_counter(p_mysql_error_type::proxysql, myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, ER_PROXYSQL_OFFLINE_SRV); } if (myds->query_retries_on_failure > 0) { myds->query_retries_on_failure--; @@ -4213,6 +4249,33 @@ int MySQL_Session::handler() { || (killed==true) // session was killed by admin ) { + // we only log in case on timing out here. Logging for 'killed' is done in the places that hold that contextual information. + if (mybe->server_myds->myconn && (mybe->server_myds->myconn->async_state_machine != ASYNC_IDLE) && mybe->server_myds->wait_until && (thread->curtime >= mybe->server_myds->wait_until)) { + std::string query {}; + + if (CurrentQuery.stmt_info == NULL) { // text protocol + query = std::string { mybe->server_myds->myconn->query.ptr, mybe->server_myds->myconn->query.length }; + } else { // prepared statement + query = std::string { CurrentQuery.stmt_info->query, CurrentQuery.stmt_info->query_length }; + } + + std::string client_addr { "" }; + int client_port = 0; + + if (client_myds) { + client_addr = client_myds->addr.addr ? client_myds->addr.addr : ""; + client_port = client_myds->addr.port; + } + + proxy_warning( + "Killing connection %s:%d because query '%s' from client '%s':%d timed out.\n", + mybe->server_myds->myconn->parent->address, + mybe->server_myds->myconn->parent->port, + query.c_str(), + client_addr.c_str(), + client_port + ); + } handler_again___new_thread_to_kill_connection(); } if (mybe->server_myds->DSS==STATE_NOT_INITIALIZED) { diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 744cff02c6..fb0b70c860 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -4837,6 +4837,7 @@ void MySQL_Thread::process_all_sessions() { if (sess->session_fast_forward) { if (sess->HasOfflineBackends()) { sess->killed=true; + proxy_warning("Killing client connection %s:%d due to 'session_fast_forward' and offline backends\n", sess->client_myds->addr.addr, sess->client_myds->addr.port); } } else { @@ -4855,6 +4856,7 @@ void MySQL_Thread::process_all_sessions() { if ( (sess_time/1000 > (unsigned long long)mysql_thread___wait_timeout) ) { sess->killed=true; sess->to_process=1; + proxy_warning("Killing client connection %s:%d because inactive for %llums\n", sess->client_myds->addr.addr, sess->client_myds->addr.port, sess_time/1000); } } #endif // IDLE_THREADS diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 82a202ebd8..22cc0971a8 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -5195,6 +5195,9 @@ ProxySQL_Admin::ProxySQL_Admin() : rand_del[4] = '-'; rand_del[5] = 0; + // Default initialize prometheus collectable flag + registered_prometheus_collectable = false; + // Initialize prometheus metrics init_prometheus_counter_array(admin_metrics_map, this->metrics.p_counter_array); init_prometheus_gauge_array(admin_metrics_map, this->metrics.p_gauge_array); diff --git a/test/tap/tests/test_session_status_flags-t.cpp b/test/tap/tests/test_session_status_flags-t.cpp index 7b83a16848..1d49b1c2f8 100644 --- a/test/tap/tests/test_session_status_flags-t.cpp +++ b/test/tap/tests/test_session_status_flags-t.cpp @@ -49,6 +49,9 @@ int main(int argc, char *argv[]) { MYSQL_QUERY(proxysql_admin, "UPDATE mysql_servers SET max_replication_lag=20"); MYSQL_QUERY(proxysql_admin, "LOAD MYSQL SERVERS TO RUNTIME"); + // Wait for ProxySQL to detect replication issues + sleep(10); + { MYSQL* proxysql_mysql = mysql_init(NULL);