From bc6d4f2aba905d6f2b2e965ec4e792160ea07931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 19 Aug 2021 12:53:22 +0200 Subject: [PATCH] Improve error verbosity in ProxySQL Cluster --- lib/ProxySQL_Cluster.cpp | 13 ++++++++++--- test/tap/tests/test_cluster1-t.cpp | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ProxySQL_Cluster.cpp b/lib/ProxySQL_Cluster.cpp index 7335d6754..8847e74ca 100644 --- a/lib/ProxySQL_Cluster.cpp +++ b/lib/ProxySQL_Cluster.cpp @@ -162,6 +162,7 @@ void * ProxySQL_Cluster_Monitor_thread(void *args) { //query = query3; //unsigned long long before_query_time2=monotonic_time(); if (update_checksum) { + unsigned long long before_query_time=monotonic_time(); rc_query = mysql_query(conn,query3); if ( rc_query == 0 ) { query_error = NULL; @@ -184,7 +185,9 @@ void * ProxySQL_Cluster_Monitor_thread(void *args) { } else { query_error = query3; if (query_error_counter == 0) { - proxy_error("Cluster: unable to run query on %s:%d using user %s : %s . Error: %s\n", node->hostname, node->port , username, query_error, mysql_error(conn)); + unsigned long long after_query_time=monotonic_time(); + unsigned long long elapsed_time_us = (after_query_time - before_query_time); + proxy_error("Cluster: unable to run query on %s:%d using user %s after %llums : %s . Error: %s\n", node->hostname, node->port , username, elapsed_time_us/1000 , query_error, mysql_error(conn)); } if (++query_error_counter == QUERY_ERROR_RATE) query_error_counter = 0; } @@ -215,7 +218,9 @@ void * ProxySQL_Cluster_Monitor_thread(void *args) { } else { query_error = query2; if (query_error_counter == 0) { - proxy_error("Cluster: unable to run query on %s:%d using user %s : %s . Error: %s\n", node->hostname, node->port , username, query_error, mysql_error(conn)); + unsigned long long after_query_time=monotonic_time(); + unsigned long long elapsed_time_us = (after_query_time - before_query_time); + proxy_error("Cluster: unable to run query on %s:%d using user %s after %llums : %s . Error: %s\n", node->hostname, node->port , username, elapsed_time_us/1000 , query_error, mysql_error(conn)); } if (++query_error_counter == QUERY_ERROR_RATE) query_error_counter = 0; } @@ -224,7 +229,9 @@ void * ProxySQL_Cluster_Monitor_thread(void *args) { } else { query_error = query1; if (query_error_counter == 0) { - proxy_error("Cluster: unable to run query on %s:%d using user %s : %s . Error: %s\n", node->hostname, node->port , username, query_error, mysql_error(conn)); + unsigned long long after_query_time=monotonic_time(); + unsigned long long elapsed_time_us = (after_query_time - start_time); + proxy_error("Cluster: unable to run query on %s:%d using user %s after %llums : %s . Error: %s\n", node->hostname, node->port , username, elapsed_time_us/1000, query_error, mysql_error(conn)); } if (++query_error_counter == QUERY_ERROR_RATE) query_error_counter = 0; } diff --git a/test/tap/tests/test_cluster1-t.cpp b/test/tap/tests/test_cluster1-t.cpp index fbd5256fc..ce017e985 100644 --- a/test/tap/tests/test_cluster1-t.cpp +++ b/test/tap/tests/test_cluster1-t.cpp @@ -207,6 +207,7 @@ int main(int argc, char** argv) { get_checksum(proxysql_admin, "mysql_variables", chk1); MYSQL_QUERY(proxysql_admin, "SET mysql-have_ssl='true'"); MYSQL_QUERY(proxysql_admin, "SET mysql-have_compress='true'"); + MYSQL_QUERY(proxysql_admin, "SET mysql-auditlog_filename=\"proxy-audit\""); MYSQL_QUERY(proxysql_admin, update_mysql_variables_1); MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); get_checksum(proxysql_admin, "mysql_variables", chk2);