Skip to content

Commit

Permalink
Merge pull request #3311 from sysown/v2.1.1-3310
Browse files Browse the repository at this point in the history
Closes #3310: Improve error reporting for 'MySQL_Monitor' and 'MySQL_Session' backend connections via counters
  • Loading branch information
renecannao authored Mar 2, 2021
2 parents 6d49f5f + 1deee92 commit 1dd24cc
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 51 deletions.
1 change: 1 addition & 0 deletions include/MySQL_Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */


Expand Down
40 changes: 40 additions & 0 deletions lib/MySQL_Monitor.cpp

Large diffs are not rendered by default.

165 changes: 114 additions & 51 deletions lib/MySQL_Session.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/ProxySQL_Admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_idx, p_admin_counter>(admin_metrics_map, this->metrics.p_counter_array);
init_prometheus_gauge_array<admin_metrics_map_idx, p_admin_gauge>(admin_metrics_map, this->metrics.p_gauge_array);
Expand Down
3 changes: 3 additions & 0 deletions test/tap/tests/test_session_status_flags-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 1dd24cc

Please sign in to comment.